Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check box raido button

Status
Not open for further replies.

raji96

Programmer
Aug 7, 2001
64
US
I have a check box and two radio buttons.

<input type=&quot;checkbox&quot; name=&quot;GA&quot; value=&quot;GA&quot;
style=&quot;background-color: rgb(239,239,239); color: rgb(239,239,239)&quot;>GA<br>&nbsp;&nbsp;
<input type=&quot;radio&quot; name=&quot;thirty&quot; value=&quot;Thirty&quot;
style=&quot;background-color: rgb(239,239,239); color: rgb(239,239,239)&quot;>\30
<input type=&quot;radio&quot; name=&quot;thirty&quot; value=&quot;Fifty &quot;
style=&quot;background-color: rgb(239,239,239); color: rgb(239,239,239)&quot;>\50<br>

The issue is when the check box is not checked, even if one of the radio buttons are checked the
value of the radio button should not be passed or set to nothing.
Since radio button cannot be cleared once it is picked i am having problem, the solution i thought
was to put another radio button 'clear' and set its value to nothing but user does not want that.

if checkbox checked then
value of radio button
else
value of radio button is nothing.

I tried to set the form variable 'thirty' to &quot;nothing&quot; from the javascript but did not work.

Any suggestions !
Thanks
Snebe
 
Just because the form data is submitted doesn't mean the receiving script must use it; put the logic in the module that processes the form data.

Your comment that Javascript cannot affect the value of the radio button is interesting. If one of the buttons in the radio group is not checked then the radio button group name will not be submitted, so it won't have a value, - since it is not there.

Try this.

Code:
<html>
<head>
	<title>Radio Button Value</title>
</head>

<body>

<form>
<input type=&quot;checkbox&quot; name=&quot;GA&quot; value=&quot;GA&quot; onclick=&quot;throttle()&quot;><br><br>
<input type=&quot;radio&quot; name=&quot;bottle_size&quot; value=&quot;thirty&quot;><br>
<input type=&quot;radio&quot; name=&quot;bottle_size&quot; value=&quot;fifty&quot;><br><br>

<input type=&quot;submit&quot;>
</form>
<script>
function throttle(){
	if(document.forms[0].GA.checked == false){
		document.forms[0].bottle_size[0].checked = false;
		document.forms[0].bottle_size[1].checked = false;
	}
}
</script>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top