Connecting Tech Pros Worldwide Help | Site Map

simple radiogroup chambawamba

Matthias H. Risse
Guest
 
Posts: n/a
#1: Jul 23 '05

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).


Expand|Select|Wrap|Line Numbers
  1. ....
  2. <input onclick="foo();" value="0" type="radio" id="qf_18d951"
  3. name="ident" checked="checked" /><label for="qf_18d951">none</label>
  4. <input onclick="foo();" value="1" type="radio" id="qf_fd9452"
  5. name="ident" /><label for="qf_fd9452">1</label>
  6.  
  7.  
  8. <input onclick="foo();" value="2" type="radio" id="qf_a9078a"
  9. name="ident" /><label for="qf_a9078a">2</label>
  10.  
  11. ....
  12.  

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.


Expand|Select|Wrap|Line Numbers
  1. function foo()
  2. {
  3. myobj = document.getElementByName('ident').value;
  4. myobj2 = document.getElementsByName('ident')[0].value;
  5. }
  6.  

anyone? tnx in adv!

//m




__
note: emails to reply-address end up in nirvana (spam, you know).
Mick White
Guest
 
Posts: n/a
#2: Jul 23 '05

re: simple radiogroup chambawamba


Matthias H. Risse wrote:
[color=blue]
>
> i want to access the current value of this radiogroup in my
> javascript function.
>
Expand|Select|Wrap|Line Numbers
  1. > ...
  2. > <input onclick="foo();" value="0" type="radio" id="qf_18d951"
  3. > name="ident" checked="checked" /><label for="qf_18d951">none</label>
  4. > <input onclick="foo();" value="1" type="radio" id="qf_fd9452"
  5. > name="ident" /><label for="qf_fd9452">1</label>
  6. >
  7. > <input onclick="foo();" value="2" type="radio" id="qf_a9078a"
  8. > name="ident" /><label for="qf_a9078a">2</label>
  9. > ...
>
>
> 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.
>
>
>
Expand|Select|Wrap|Line Numbers
  1. > function foo()
  2. > {
  3. >     myobj = document.getElementByName('ident').value;
  4. >     myobj2 = document.getElementsByName('ident')[0].value;
  5. > }
>[/color]

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