simple radiogroup chambawamba

  • Thread starter Matthias H. Risse
  • Start date
M

Matthias H. Risse

hi

i want to access the current value of this radiogroup in my
javascript function. unfortunately the id's are changing
on every request (some hash thing of pear.php.net::html_quickform-package).


Code:
....
<input onclick="foo();" value="0" type="radio" id="qf_18d951"
name="ident" checked="checked" /><label for="qf_18d951">none</label>
<input onclick="foo();" value="1" type="radio" id="qf_fd9452"
name="ident" /><label for="qf_fd9452">1</label>


<input onclick="foo();" value="2" type="radio" id="qf_a9078a"
name="ident" /><label for="qf_a9078a">2</label>

....


here is what did _not_ work out, because i somehow dont
get a valid object in IE6 nor in a later Gecko. i am sure
i mixed something silly up, but i just cannot spot it.


Code:
function foo()
{
myobj = document.getElementByName('ident').value;
myobj2 = document.getElementsByName('ident')[0].value;
}


anyone? tnx in adv!

//m




__
note: emails to reply-address end up in nirvana (spam, you know).
 
M

Mick White

Matthias said:
i want to access the current value of this radiogroup in my
javascript function.
Code:
...
<input onclick="foo();" value="0" type="radio" id="qf_18d951"
name="ident" checked="checked" /><label for="qf_18d951">none</label>
<input onclick="foo();" value="1" type="radio" id="qf_fd9452"
name="ident" /><label for="qf_fd9452">1</label>

<input onclick="foo();" value="2" type="radio" id="qf_a9078a"
name="ident" /><label for="qf_a9078a">2</label>
...


here is what did _not_ work out, because i somehow dont
get a valid object in IE6 nor in a later Gecko. i am sure
i mixed something silly up, but i just cannot spot it.


Code:
function foo()
{
myobj = document.getElementByName('ident').value;
myobj2 = document.getElementsByName('ident')[0].value;
}

function foo(){
d=document.forms[0].elements['ident'];
for(i=0;i<d.length;i++){
if(d.checked){
return d.value
}
}
return "Not selected"
}
Mick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,794
Messages
2,569,641
Members
45,354
Latest member
OrenKrause

Latest Threads

Top