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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting radio buttons

Status
Not open for further replies.

awingnut

Programmer
Feb 24, 2003
759
US
After struggling with some syntax problems in my first javascript, I have something that is 50% there. The following is working:
Code:
<head>
.
.
.
<script language=&quot;javascript&quot; type=&quot;text/javascript&quot;>
	<!--
		function verify_reject(button_name,file_name)
		{
			if (!confirm(&quot;Rejecting &quot; + file_name + &quot; will remove it from the server.&quot;))
			{
				button_name.checked=false;
			}
		}
	//-->
</script>
</head>
Later in a form I have sets of 3 radio buttons (one set is presented for simplicity):
Code:
<input type=&quot;radio&quot; name=&quot;Disposition1&quot; value=&quot;Approve&quot;>
<input type=&quot;radio&quot; name=&quot;Disposition1&quot; value=&quot;Reject&quot; onClick=&quot;verify_reject(this,'Intro ad.wav')&quot;>
<input type=&quot;radio&quot; name=&quot;Disposition1&quot; value=&quot;Defer&quot; CHECKED>
A negative confirmation turns 'off' the &quot;Reject&quot; button as it should. However, I cannot have all of the buttons 'off' which is the case after a negative confirmation. I cannot figure out how to refer to the &quot;Defer&quot; button, within the function, to turn it 'on' once the &quot;Reject&quot; has been turned 'off'.

Thanks for any help.
 
radio buttons are kind of arrays.
so you reffer to them by file_name.radio_name.[1, 2 or 3].value = 0 or 1 (i think)
 
actually this is more precise
document.Form.radio_button.checked==true
 
Thanks for the reply. I must not have the syntax correct. I get errors about [3] not expected or something like that. I guess I need to add a third variable to the function call for the button set name.

function verify_reject(button_name,file_name,button_set_name)

Then I use what?

button_set_name[3].checked=true;
 
remember that the first button is [0] just like all javascript arrays. Therefore, the third button is [2]...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
Thanks. It took me a while to get the syntax and that was the real problem. What finally worked was:

document.SORSAdministration[button_set_name][2].checked=true;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top