Javascript 是否可以在不同页面中获取单选按钮的值?

Javascript 是否可以在不同页面中获取单选按钮的值?,javascript,Javascript,我没有发布所有的html代码,但我给出了一个html示例 如果我有4页,是否可以获得每页选中的单选按钮的所有值 第1页 <table> <tbody> <tr class="choices1"> <td align="center"><input id="r1" name="radio" type="radio" value="Stop" /></td> <td>Stop</td> </tr&g

我没有发布所有的html代码,但我给出了一个html示例

如果我有4页,是否可以获得每页选中的单选按钮的所有值

第1页

<table>
<tbody>
<tr class="choices1">
<td align="center"><input id="r1" name="radio" type="radio" value="Stop" /></td>
<td>Stop</td>
</tr>
<tr class="choices2">
<td align="center"><input id="r2" name="radio" type="radio" value="Go" /></td>
<td>Go</td>
</tr>
<tr class="choices1">
<td align="center"><input id="r3" name="radio" type="radio" value="Ready" /></td>
<td>Ready</td>
</tr>
<tr class="choices2">
<td align="center"><input id="r4" name="radio" type="radio" value="Fly" /></td>
<td>Fly</td>
</tr>
</tbody>
</table>

停止
去
准备好的
飞
我的代码

// this is the code that i'm using to get the value of the radio button that is checked. 
// this code is working for 1 page only.
function findSelection(field) {
    var test = document.getElementsByName(field);
    var q1 = 0, q2 = 0;
    var score = 0;

    for (i=0; i < test.length; i++) {
        if (test[i].checked==true) {     
            return (test[i].value);         
        }
    }
}

    function submit() {
        var choice =  findSelection("radio");
        alert(choice);
        return false;
    }
//这是我用来获取选中单选按钮值的代码。
//此代码仅适用于1页。
函数findSelection(字段){
var test=document.getElementsByName(字段);
var q1=0,q2=0;
var得分=0;
对于(i=0;i
您可以将onClick事件绑定到输入元素

<table>
<tbody>
    <tr class="choices1">
        <td align="center">
            <input id="r1" name="radio" type="radio" value="Stop" onclick="myFunction(this);" />
        </td>
        <td>Stop</td>
    </tr>
    <tr class="choices2">
        <td align="center">
            <input id="r2" name="radio" type="radio" value="Go" onclick="myFunction(this);" />
        </td>
        <td>Go</td>
    </tr>
    <tr class="choices1">
        <td align="center">
            <input id="r3" name="radio" type="radio" value="Ready" onclick="myFunction(this);" />
        </td>
        <td>Ready</td>
    </tr>
    <tr class="choices2">
        <td align="center">
            <input id="r4" name="radio" type="radio" value="Fly" onclick="myFunction(this);" />
        </td>
        <td>Fly</td>
    </tr>
</tbody>

使用类似于test.htm的querystring将值传递到下一页?id=123是的,将它们传递到下一页,或将它们保存到服务器。您能给我一个示例代码吗?在URL中使用querystring传递它们,或将它们保存到会话中,或将它们保存到服务器上
 function myFunction(id) {
    alert(id.value);
}