onselect() +reload

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
bob_the _builder
Forum Contributor
Posts: 131
Joined: Sat Aug 28, 2004 12:25 am

onselect() +reload

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Take a look at what are often called jump-menus
bob_the _builder
Forum Contributor
Posts: 131
Joined: Sat Aug 28, 2004 12:25 am

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
bob_the _builder
Forum Contributor
Posts: 131
Joined: Sat Aug 28, 2004 12:25 am

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Your code is for a jump-menu still.
bob_the _builder
Forum Contributor
Posts: 131
Joined: Sat Aug 28, 2004 12:25 am

Post by bob_the _builder »

Hi,

is:

<select name="monthnum" onChange="form.submit()">

the answer?


Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

feyd wrote:Your onselect event would fill a hidden field and submit the form.
bob_the _builder
Forum Contributor
Posts: 131
Joined: Sat Aug 28, 2004 12:25 am

Post 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
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

~feyd has told you twice what you need to do.
  1. Make your select box set the value of "prev" when its value is changed. There are LOTS of examples of this online.
  2. 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply