Page 1 of 1
onselect() +reload
Posted: Wed May 16, 2007 5:34 pm
by bob_the _builder
Hi,
How does one go about having a listmenu, when a user makes a selection, have it reload the page so the post data can me selected?
Thanks
Posted: Wed May 16, 2007 5:35 pm
by feyd
Take a look at what are often called jump-menus
Posted: Wed May 16, 2007 6:25 pm
by bob_the _builder
Hi,
Thanks, I did look at that option. Problem is that I dont want it to jump to another url.
I am wanting it to reload the page and post the data.
value"" needs to hold value"Jan" not a url:
Code: Select all
<form action="../calendar.php" method="get">
<select id="month" name="month">
<option '.( $month==Jan ? 'selected' : '' ).' value="Jan">Jan</option>
<option '.( $month==Feb ? 'selected' : '' ).' value="Feb">Feb</option>
<option '.( $month==Mar ? 'selected' : '' ).' value="Mar">Mar</option>
<option '.( $month==Apr ? 'selected' : '' ).' value="Apr">Apr</option>
<option '.( $month==May ? 'selected' : '' ).' value="May">May</option>
<option '.( $month==Jun ? 'selected' : '' ).' value="Jun">Jun</option>
<option '.( $month==Jul ? 'selected' : '' ).' value="Jul">Jul</option>
<option '.( $month==Aug ? 'selected' : '' ).' value="Aug">Aug</option>
<option '.( $month==Sep ? 'selected' : '' ).' value="Sep">Sep</option>
<option '.( $month==Oct ? 'selected' : '' ).' value="Oct">Oct</option>
<option '.( $month==Nov ? 'selected' : '' ).' value="Nov">Nov</option>
<option '.( $month==Dec ? 'selected' : '' ).' value="Dec">Dec</option>
</select>
</form>
Thanks
Posted: Wed May 16, 2007 7:00 pm
by feyd
True, it's not a jump-menu, but it is the same concept. Your onselect event would fill a hidden field and submit the form.
Posted: Thu May 17, 2007 12:32 am
by bob_the _builder
Hi,
Still not doing very well, so far I have the onselect() working but its not posting the form data:
Code: Select all
<form action="../calendar.php" method="get">
<select name="monthnum" onchange="window.location=\'../calendar.php\'">
<option '.( $monthnum=='Jan' ? 'selected' : '' ).' value="Jan">Jan</option>
<option '.( $monthnum=='Feb' ? 'selected' : '' ).' value="Feb">Feb</option>
<option '.( $monthnum=='Mar' ? 'selected' : '' ).' value="Mar">Mar</option>
<option '.( $monthnum=='Apr' ? 'selected' : '' ).' value="Apr">Apr</option>
<option '.( $monthnum=='May' ? 'selected' : '' ).' value="May">May</option>
<option '.( $monthnum=='Jun' ? 'selected' : '' ).' value="Jun">Jun</option>
<option '.( $monthnum=='Jul' ? 'selected' : '' ).' value="Jul">Jul</option>
<option '.( $monthnum=='Aug' ? 'selected' : '' ).' value="Aug">Aug</option>
<option '.( $monthnum=='Sep' ? 'selected' : '' ).' value="Sep">Sep</option>
<option '.( $monthnum=='Oct' ? 'selected' : '' ).' value="Oct">Oct</option>
<option '.( $monthnum=='Nov' ? 'selected' : '' ).' value="Nov">Nov</option>
<option '.( $monthnum=='Dec' ? 'selected' : '' ).' value="Dec">Dec</option>
<input name="prev" type="hidden" value="prev">
</select>
</form>
I guess I am missing something?
Thanks
Posted: Thu May 17, 2007 12:34 am
by feyd
Your code is for a jump-menu still.
Posted: Thu May 17, 2007 12:49 am
by bob_the _builder
Hi,
is:
<select name="monthnum" onChange="form.submit()">
the answer?
Thanks
Posted: Thu May 17, 2007 12:55 am
by feyd
feyd wrote:Your onselect event would fill a hidden field and submit the form.
Posted: Thu May 17, 2007 1:39 am
by bob_the _builder
This is what I have at the moment, is it fit for the job?
Code: Select all
<form action="../calendar.php" method="get">
<select name="monthnow" onChange="form.submit()">
<option '.( $monthnow=='1' ? 'selected' : '' ).' value="1">Jan</option>
<option '.( $monthnow=='2' ? 'selected' : '' ).' value="2">Feb</option>
<option '.( $monthnow=='3' ? 'selected' : '' ).' value="3">Mar</option>
<option '.( $monthnow=='4' ? 'selected' : '' ).' value="4">Apr</option>
<option '.( $monthnow=='5' ? 'selected' : '' ).' value="5">May</option>
<option '.( $monthnow=='6' ? 'selected' : '' ).' value="6">Jun</option>
<option '.( $monthnow=='7' ? 'selected' : '' ).' value="7">Jul</option>
<option '.( $monthnow=='8' ? 'selected' : '' ).' value="8">Aug</option>
<option '.( $monthnow=='9' ? 'selected' : '' ).' value="9">Sep</option>
<option '.( $monthnow=='10' ? 'selected' : '' ).' value="10">Oct</option>
<option '.( $monthnow=='11' ? 'selected' : '' ).' value="11">Nov</option>
<option '.( $monthnow=='12' ? 'selected' : '' ).' value="12">Dec</option>
<input name="prev" type="hidden" value="">
</select>
</form>
Thanks
Posted: Thu May 17, 2007 9:59 am
by pickle
~feyd has told you twice what you need to do.
- Make your select box set the value of "prev" when its value is changed. There are LOTS of examples of this online.
- Submit the form. Again, there are lots of examples of how to reference a form online, and yes, submit() is the proper function.
Likely your best bet is to use document.getElementById() syntax.