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

radiobuttons 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?
 
Hi Wim,

Try this:

<input type=&quot;radio&quot; name=&quot;rbname&quot; value=&quot;1&quot; onClick=&quot;{window.alert(value);}&quot;> 1
<input type=&quot;radio&quot; name=&quot;rbname&quot; value=&quot;2&quot; onClick=&quot;{window.alert(value);}&quot;> 2
<input type=&quot;radio&quot; name=&quot;rbname&quot; value=&quot;3&quot; onClick=&quot;{window.alert(value);}&quot;> 3


Good luck,
Erik

 
Hi Wim,

Forget my first answer. I think this works better :

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


In your case, with the javascript, you can also use 2 different options:

FIRST: use &quot;GoNext(value)&quot; in stead off
&quot;GoNext(rbname.value)&quot; like:

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

SECOND: name=&quot;rbname#&quot; and &quot;GoNext(rbname#.value)&quot; like:

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



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


Good luck again,
Erik

 
Hi Wim and everybodey else,

I think I had a black out !!!

Off course my SECOND option is NOT WORKING !!!!
you can not use exclusive names.

SORRY

You see, don't believe everything that people say. First see and than believe !!!

Erik
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top