Menu control in javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yves PEYSSON

    Menu control in javascript

    Ji, my problem is simple. I would like to set dynamically the pressed item
    of a menu of a form in javascript. First, how to get the value of the item
    that has been selected with the mouse. Then how to set it in javascript. I
    don't know the object name. I do that like form.myfield.va lue = xxxx with an
    input text, but it it doesnot work for menu !


    Thanks for the help

    Yves




  • @SM

    #2
    Re: Menu control in javascript

    Yves PEYSSON a ecrit :
    [color=blue]
    > Ji, my problem is simple. I would like to set dynamically the pressed item
    > of a menu of a form in javascript. First, how to get the value of the item
    > that has been selected with the mouse. Then how to set it in javascript. I
    > don't know the object name. I do that like form.myfield.va lue = xxxx with an
    > input text, but it it doesnot work for menu ![/color]

    Example :
    <form action="" method="get">
    <select onchange= if(this.options .selectedIndex= =0)
    alert('Do an other choice');
    else
    this.form.actio n=this.options[this.options.se lectedIndex].value;">
    <option selected>Choisi r une ville - Select a Town
    <option value="Paris.ht m">Paris
    <option value="London.h tm">Londres - London
    <option value="Tokio.ht m">Tokio
    </select>
    <input type=submit value="GO !">
    </form>

    others possibilities :

    this.form.myTex tField.value=th is.options[this.options.se lectedIndex].value;
    alert('Destinat ion = '+this.options[this.options.se lectedIndex].value);
    self.location=t his.options[this.options.se lectedIndex].value;

    and so on ...

    --
    *************** *************** *************** *************** **
    Stéphane MORIAUX : mailto:stephane OTER-MOImoriaux@wana doo.fr
    Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)

    *************** *************** *************** *************** **


    Comment

    Working...