simple radiogroup chambawamba

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matthias H. Risse

    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::h tml_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).
  • Mick White

    #2
    Re: simple radiogroup chambawamba

    Matthias H. Risse wrote:
    [color=blue]
    >
    > 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;
    > }
    >
    >[/color]

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

    Comment

    Working...