[Javascript] Newbie question

Schalk schalk at volume4.com
Thu Dec 1 12:39:40 CST 2005


Peter Brunone wrote:
> 	You can get any radio button with
>
> var myButton = document.getElementById("radioButtonID")
>
> and check its .checked property (true or false)...
>
> Or you can get an entire set (multiple radio buttons sharing a name)
> with 
>
> var myButtons = document.forms.formName.radioButtonName
>
> This yields an array, which you can iterate through
>
> for(var i=0;i<myButtons.length;i++) {
> 	if(myButtons[i].checked) {
> 		//do something with myButtons[i].value, 
> 		// which is probably how you identify it
> 		}
> 	}
Thanks Peter, that will help but, maybe I should rephrase my question. I have a form and at the end I give the user between 2 - 3 payment options. When they click on one of these (radio buttons) the appropriate form fields should show below these radio buttons.

If for example the user chooses credit card, onlt fields relevant to a credit card should show and all others hidden and so forth. Thanks!

-- 
Kind Regards
Schalk Neethling
Web Developer.Designer.Programmer.President
Volume4.Business.Solution.Developers





More information about the Javascript mailing list