...

View Full Version : Help with javascript and form fields



bpoppa
12-21-2003, 10:55 PM
Hello,

I am still developing my javascript skills and have a question.

Say I have two radio buttons with the same name but different value. Selecting one of the radios is required. There are two text fields and depending on which radio is selected, one of the two text fields would be required.

So I have radios named "type" one value is "current" and one is "new".

If new is selected, then the text field "pbname" is requireed. If new is selected then the text field "reqno" is required.

I have spent about 5 hours scouring the net for examples, so if there is somewhere I can look, please help.

Thanks!

Jim

requestcode
12-22-2003, 01:22 PM
With radio buttons that have the same name the browser would set them up in an array so you could determine if one or the other has been "checked" like this:
if(document.form_name.type[0].checked)
{do something}
else
{do something}

This would determine if the first radio button has been checked and if it has perform the statements within the first set of curly brackets. If not then do the statements in the next set of brackets (else). Hope that helps.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum