470,826 Members | 2,090 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,826 developers. It's quick & easy.

simple radiogroup chambawamba


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).
Jul 23 '05 #1
1 988
Matthias H. Risse wrote:

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.  <input onclick="foo();" value="2" type="radio" id="qf_a9078a"
  7.  name="ident" /><label for="qf_a9078a">2</label>
  8.  ...
  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.  }
  6.  


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
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by delisonews | last post: by
3 posts views Thread by Patchwork | last post: by
7 posts views Thread by abcd | last post: by
14 posts views Thread by Giancarlo Berenz | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.