radiobutton

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • alain dhaene

    radiobutton

    Hi,

    I have follow problem:
    The function don't reconigze the radiobutton of is it something else?

    function bericht(form)
    {
    .....

    alert(form.RKop tekst.value); // wrong : gives UNDIFENED
    alert(form.TKop tekst.value); //ok
    ...
    }



    <FORM method = "post" name="bestel" Action="frmseto pties.php"
    onSubmit="retur n bericht(this);" >
    ....

    <input type="radio" value="0" name="RKoptekst ">Geen
    gepersonaliseer de koptekst


    <input type="radio" name="RKoptekst " value="1">Volge nde
    gepersonaliseer de koptekst:


    <input type="text" name="TKoptekst " size="38"></p>

    ....
    </FORM>

    thx,

    Leonard


  • Michael Winter

    #2
    Re: radiobutton

    On Tue, 24 Feb 2004 10:25:47 +0100, alain dhaene <a.dhaene@instr uct.be>
    wrote:
    [color=blue]
    > I have follow problem:
    > The function don't reconigze the radiobutton of is it something else?
    >
    > function bericht(form)
    > {
    > alert(form.RKop tekst.value); // wrong : gives UNDIFENED
    > alert(form.TKop tekst.value); //ok
    > }
    >
    > <FORM method = "post" name="bestel" Action="frmseto pties.php"
    > onSubmit="retur n bericht(this);" >
    >
    > <input type="radio" value="0" name="RKoptekst ">Geen
    > gepersonaliseer de koptekst
    > <input type="radio" name="RKoptekst " value="1">Volge nde
    > gepersonaliseer de koptekst:[/color]

    It's something else.

    There are two radio buttons with the name, RKoptekst. When you reference
    that name, as in form.RKoptekst, a collection is returned which contains
    all elements in 'form' with the name 'RKoptekst', not the currently
    selected button in that group.

    To find the currently selected button, and its value, you can use
    something like:

    function findSelected( group ) {
    var size = group.length;
    for( var i = 0; i < size; ++i ) {
    if( group[ i ].checked ) return i;
    }
    }

    function bericht( form ) {
    alert( form.RKoptekst[ findSelected( form.RKoptekst )].value );
    alert( form.TKoptekst. value );
    }

    Hope that helps,
    Mike

    --
    Michael Winter
    M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

    Comment

    • alain dhaene

      #3
      Re: radiobutton

      it works.
      thx
      "Michael Winter" <M.Winter@bluey onder.co.invali d> schreef in bericht
      news:opr3vge4bk 5vklcq@news-text.blueyonder .co.uk...[color=blue]
      > On Tue, 24 Feb 2004 10:25:47 +0100, alain dhaene <a.dhaene@instr uct.be>
      > wrote:
      >[color=green]
      > > I have follow problem:
      > > The function don't reconigze the radiobutton of is it something else?
      > >
      > > function bericht(form)
      > > {
      > > alert(form.RKop tekst.value); // wrong : gives UNDIFENED
      > > alert(form.TKop tekst.value); //ok
      > > }
      > >
      > > <FORM method = "post" name="bestel" Action="frmseto pties.php"
      > > onSubmit="retur n bericht(this);" >
      > >
      > > <input type="radio" value="0" name="RKoptekst ">Geen
      > > gepersonaliseer de koptekst
      > > <input type="radio" name="RKoptekst " value="1">Volge nde
      > > gepersonaliseer de koptekst:[/color]
      >
      > It's something else.
      >
      > There are two radio buttons with the name, RKoptekst. When you reference
      > that name, as in form.RKoptekst, a collection is returned which contains
      > all elements in 'form' with the name 'RKoptekst', not the currently
      > selected button in that group.
      >
      > To find the currently selected button, and its value, you can use
      > something like:
      >
      > function findSelected( group ) {
      > var size = group.length;
      > for( var i = 0; i < size; ++i ) {
      > if( group[ i ].checked ) return i;
      > }
      > }
      >
      > function bericht( form ) {
      > alert( form.RKoptekst[ findSelected( form.RKoptekst )].value );
      > alert( form.TKoptekst. value );
      > }
      >
      > Hope that helps,
      > Mike
      >
      > --
      > Michael Winter
      > M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)[/color]


      Comment

      Working...