0

我有一个 jsp 页面,我在其中放置了几个单选按钮。

选择单选按钮并单击提交按钮后,它将调用一个javascript函数,该函数需要单选按钮的选定值才能对脚本执行一些操作。

谁能解决这个问题?

<td align="center"><input type="radio" name="radio" id="radio" value="value1"></td>
<td align="center"><input type="radio" name="radio" id="radio" value="value2"></td>
<td align="center"><input type="radio" name="radio" id="radio" value="value3"></td>

<td ><a onclick="Javascript:delete();"><span>Delete</span></a></td>

<script language="javascript" type="text/javascript">
function delete()
{
    <% String str= here i want that selected radio buttons value%>
}
</script>
4

1 回答 1

0
<script language="javascript" type="text/javascript">
        function deleteme() {
            var values = document.getElementsByName('radio');

            for ( var i = 0, length = values.length; i < length; i++) {
                if (values[i].checked) {
                    // do whatever you want with the checked radio
                    alert(values[i].value);
                    // only one radio can be logically checked, don't check the rest
                    break;
                }
            }
        }
    </script>

    <td align="center"><input type="radio" name="radio" id="radio" value="value1">value1</td>
    <td align="center"><input type="radio" name="radio" id="radio" value="value2">value2</td>
    <td align="center"><input type="radio" name="radio" id="radio" value="value3">value3</td>

    <td><a onclick="deleteme();">Delete</a></td>
于 2013-10-25T13:36:09.347 回答