Connecting Tech Pros Worldwide Help | Site Map

simple radiogroup chambawamba

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 11:24 AM
Matthias H. Risse
Guest
 
Posts: n/a
Default 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).

  #2  
Old July 23rd, 2005, 11:24 AM
Mick White
Guest
 
Posts: n/a
Default 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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.