Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: radio buttons validation


Message #1 by "taherm@f... on Tue, 26 Feb 2002 15:53:19

i have below 2 radio buttons in a form..



i want a javascript that when the form is submitted it should alert the 

user of the name value of teh radio button selected..



<form ....>

<input type="radio" name="PayMethod" value="PayByAccount">

<input type="radio" name="PayMethod" value="PayByCard" checked>

</form>                                          



Please let me know

Thanks
Message #2 by Mark Eckeard <meckeard2000@y...> on Tue, 26 Feb 2002 08:34:36 -0800 (PST)
Try this:



function CheckValue(){



	var go;

	

	for (go = 0; go <

document.inputform.PayMethod.length; go++){



		

	if (document.inputform.PayMethod[go].checked){

		alert(document.inputform.PayMethod[go].value);

		}

	}

}



You will need to add a button that calls the function

and add the form name to your form tag.  But I tested

it and it works.



Mark.

--- "taherm@f..."

<taherm@f...> wrote:

> 

> i have below 2 radio buttons in a form..

> 

> i want a javascript that when the form is submitted

> it should alert the 

> user of the name value of teh radio button

> selected..

> 

> <form ....>

> <input type="radio" name="PayMethod"

> value="PayByAccount">

> <input type="radio" name="PayMethod"

> value="PayByCard" checked>

> </form>                                          

> 

> Please let me know

> Thanks





$subst('Email.Unsub').





__________________________________________________

Do You Yahoo!?

Yahoo! Sports - Coverage of the 2002 Olympic Games

http://sports.yahoo.com

Message #3 by "Drew, Ron" <RDrew@B...> on Wed, 27 Feb 2002 08:49:10 -0500
Do a call on the submit button to javascript..assuming formname is

frm..case sensitive

<script language=3D"javascript">

function onSubmit{

	if(document.frm.PayAccount.checked=3Dtrue){

	alert (PayByAccount pressed)

	}else{

	alert (PayByCard pressed)

	}

}

</script>

<form ....>

<input type=3D"radio" name=3D"PayAccount" value=3D"PayByAccount">

<input type=3D"radio" name=3D"PayCard" value=3D"PayByCard" checked>

</form>





-----Original Message-----

From: taherm@f...

[mailto:taherm@f...]

Sent: Tuesday, February 26, 2002 10:53 AM

To: ASP Web HowTo

Subject: [asp_web_howto] radio buttons validation







i have below 2 radio buttons in a form..



i want a javascript that when the form is submitted it should alert the

user of the name value of teh radio button selected..



<form ....>

<input type=3D"radio" name=3D"PayMethod" value=3D"PayByAccount">

<input type=3D"radio" name=3D"PayMethod" value=3D"PayByCard" checked>

</form>                                         



Please let me know

Thanks




$subst('Email.Unsub').


  Return to Index