drop down menu question

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

drop down menu question

Post by John Cartwright »

how do you make it so when a drop down item is selected the form is submitted?

any help is much appreciated TY!
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

onClick(document.form.submit);
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

onchange=""

actually..

use this.options[this.selectedIndex].value to retrieve the value (within the page).
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

after a google i come up with this

Code: Select all

<?php
<select name="mapsearch" onChange="document.form.submit();" >
?>
but it gives me the error:
blah blah document.form is not an object or is null
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

omg im so stupid forgot to rename the form name :P
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

this.form.submit() works too ;)
User avatar
Vincent Puglia
Forum Commoner
Posts: 67
Joined: Thu Sep 04, 2003 4:20 pm
Location: where the World once stood

Post by Vincent Puglia »

Hi,

any of the following would work:

Code: Select all

<select name="mapsearch" onChange="document.formname.submit();" >
 // where formname is the actual name of the form.
<select name="mapsearch" onChange="document.forms&#1111;'formname'].submit();" > 
// same as above
<select name="mapsearch" onChange="document.forms&#1111;0].submit();" > 
// where the form is the first form on the page -- forms&#1111;1] the second form, etc...
<select name="mapsearch" onChange="this.form.submit();" > 
// feyd's suggestion and the most often used.
Vinny

feyd | added

Code: Select all

tags [/color]
Post Reply