i put a few radio buttons on a form but when i click more then one they all stay selected. how can i make them deselect when a different one is clicked?
Printable View
i put a few radio buttons on a form but when i click more then one they all stay selected. how can i make them deselect when a different one is clicked?
<form method="POST" action="Whatever">
<p><input type="radio" value="V1" name="R1"></p>
<p><input type="radio" value="V2" name="R1"></p>
<p><input type="radio" value="V3" name="R1"></p>
<p><input type="radio" value="V4" checked name="R1"><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
Make sure all of the radio buttons on the form have the same name, "R1" In this example.
how do i figure out which one is checked?
<%
x = Request.form("R1")
%>
x will be the value of the radio button selected
If the first radio button is selected then x will be
equal to "V1"
This is a VBScript Example I'm sure some one here knows the javascript code. I don't off the top of my head.
how do i use vbscript in a web page? do i just type it in with the HTML and javascripts?
also if i am using a textarea how can i tell if someone presses return? when i add it on to a url it just string it all together.
Here perhaps this code can bring you an idea how to use mutiply controls with indexes and how to catch the key event of your browser. :cool:
Code:<html>
<head>
<title></title>
<script language=javascript>
<!--
function Continue_onclick() {
for ( i=0; 0<rd.length; i++ ) {
if ( rd[i].checked == true ) {
alert ( 'You have selected ' + rd[i].value );
break;
}
}
}
function document_onkeydown() {
var sEnter = '13';
if ( window.event.keyCode.toString() == sEnter ){
alert ( 'You have pressed the Enter key!' );
}
}
//-->
</script>
<script language=javascript for=document event=onkeydown>
<!--
document_onkeydown()
//-->
</script>
</head>
<body>
<table id="oTable" name="oTable">
<tr>
<td>
<input type="radio" id="rd" name="rd" value="Red" checked>Red<br>
<input type="radio" id="rd" name="rd" value="Green">Green<br>
<input type="radio" id="rd" name="rd" value="Blue">Blue<br>
<input type="radio" id="rd" name="rd" value="Black">Black
</td>
</tr>
<tr>
<td>
<input type="button" value="Button" id="Continue" name="Continue" LANGUAGE=javascript onclick="return Continue_onclick()">
</td>
</tr>
</table>
</body>
</html>
Ok this is the client but how do I get these values at the server side?
Thanks
You can use Request("rd") to get the values. But i think you need to split up the string. :rolleyes: