470,600 Members | 1,480 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

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.value = xxxx with an
input text, but it it doesnot work for menu !
Thanks for the help

Yves


Jul 20 '05 #1
1 3363
@SM
Yves PEYSSON a ecrit :
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.value = xxxx with an
input text, but it it doesnot work for menu !


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

others possibilities :

this.form.myTextField.value=this.options[this.options.selectedIndex].value;
alert('Destination = '+this.options[this.options.selectedIndex].value);
self.location=this.options[this.options.selectedIndex].value;

and so on ...

--
************************************************** ************
Stéphane MORIAUX : mailto:st*********************@wanadoo.fr
Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
http://perso.wanadoo.fr/stephane.moriaux/internet/
************************************************** ************
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Gleeman | last post: by
1 post views Thread by CW | last post: by
3 posts views Thread by John | last post: by
5 posts views Thread by Victor | last post: by
reply views Thread by BooGhost | last post: by
3 posts views Thread by =?Utf-8?B?VG9tIFc=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.