By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,843 Members | 2,324 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,843 IT Pros & Developers. It's quick & easy.

Menu control in javascript

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
@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.