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

radiobuttons and onclick

Status
Not open for further replies.

KryptoS

Programmer
Feb 7, 2001
240
BE
Hi,

I have some radiobuttons in on my page now this is the code:

<input type=&quot;radio&quot; name=&quot;rbname&quot; value=&quot;1&quot; onClick=&quot;GoNext(rbname.value)&quot;> 1
<input type=&quot;radio&quot; name=&quot;rbname&quot; value=&quot;2&quot; onClick=&quot;GoNext(rbname.value)&quot;> 2
<input type=&quot;radio&quot; name=&quot;rbname&quot; value=&quot;3&quot; onClick=&quot;GoNext(rbname.value)&quot;> 3

<script language=javascript>
function GoNext(rbvalue)
{
alert(rbvalue)
}
</script>

Why don't I get a messagebox with the value of my radio button? It says: undefined, and I saw elsewhere that maybe you can use onClick=&quot;GoNext(this)&quot; or something but I can't use 'this' ...

can someone help me?
 
Why can't you use this? It does what you need ...

<input type=&quot;radio&quot; name=&quot;rbname&quot; value=&quot;1&quot; onClick=&quot;GoNext(this.value)&quot;> 1
<input type=&quot;radio&quot; name=&quot;rbname&quot; value=&quot;2&quot; onClick=&quot;GoNext(this.value)&quot;> 2
<input type=&quot;radio&quot; name=&quot;rbname&quot; value=&quot;3&quot; onClick=&quot;GoNext(this.value)&quot;> 3

<script language=javascript>
function GoNext(rbvalue)
{
alert(rbvalue)
}
</script>

Greg.
 
IE (at least) seems to have problems with using the value attribute of a radio button. You may have to use radioButton[n].checked instead, then set a variable with the value that the radio button should have returned. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top