Drop down menu & a submit button

O

Olly

I need a script that is not server side at all. I need a user to be
able to select a month from a drop down box, and then the year from
another. But to run I need them to be able to click a button to set
the script running.

The month options will be bookmarks (eg: #jan), and the year will to a
different page (eg: 2003.html).
 
O

Olly

I need a script that is not server side at all. I need a user to be
able to select a month from a drop down box, and then the year from
another. But to run I need them to be able to click a button to set
the script running.

The month options will be bookmarks (eg: #jan), and the year will to a
different page (eg: 2003.html).

I've now found a script that can manage only one drop down menu but i
need mine to use two:

<form name="jump">
<select name="month">
<option value="#jan">January</option>
<option value="#feb">Febuary</option>
<option value="#mar">March</option>
<option value="#apr">April</option>
<option value="#may">May</option>
</select>

<select name="year">
<option value="index.html">2004</option>
<option value="2003.html">2003</option>
</select>

<input type="button"
onClick="location=document.jump.month.options[document.jump.month.selectedIndex].value;"
value="GO">
</form>
 
M

Mick White

Olly said:
<form name="jump">
<select name="month">
<option value="#jan">January</option>
<option value="#feb">Febuary</option>
<option value="#mar">March</option>
<option value="#apr">April</option>
<option value="#may">May</option>
</select>

<select name="year">
<option value="index.html">2004</option>
<option value="2003.html">2003</option>
</select>

<input type="button"
onClick="location=document.jump.month.options[document.jump.month.selectedIndex].value;"
value="GO">
</form>

onclick= "location=this.year.options[this.year.selectedIndex].value+
this.month.options[this.month.selectedIndex].value;"
Mick
 
L

Lee

Olly said:
have i added the code in right cos it still doesn't work:
<form name="jump">
<select name="month">
<option value="#jan">January</option>
<option value="#feb">Febuary</option>
<option value="#mar">March</option>
<option value="#apr">April</option>
<option value="#may">May</option>
</select>

<select name="year">
<option value="index.html">2004</option>
<option value="2003.html">2003</option>
</select>

<input type="button"
onclick="location=this.year.options[this.year.selectedIndex].value+this.mont
h.options[this.month.selectedIndex].value;" value="GO">
</form>

1. Remove the ".html" from the values of your year options,
or you'll end up trying to find a page named "2003.html#may".
2. In the context of a button's onclick handler, "this" refers
to the button. The button doesn't have year and month attributes.

onclick="f=this.form;location=f.year.options[f.year.selectedIndex].value+f.month.options[f.month.selectedIndex].value+'.html'"
 
L

Lee

Olly said:
Lee said:
Olly said:
have i added the code in right cos it still doesn't work:
<form name="jump">
<select name="month">
<option value="#jan">January</option>
<option value="#feb">Febuary</option>
<option value="#mar">March</option>
<option value="#apr">April</option>
<option value="#may">May</option>
</select>

<select name="year">
<option value="index.html">2004</option>
<option value="2003.html">2003</option>
</select>

<input type="button"
onclick="location=this.year.options[this.year.selectedIndex].value+this.mon
t
h.options[this.month.selectedIndex].value;" value="GO">
</form>

1. Remove the ".html" from the values of your year options,
or you'll end up trying to find a page named "2003.html#may".
2. In the context of a button's onclick handler, "this" refers
to the button. The button doesn't have year and month attributes.

onclick="f=this.form;location=f.year.options[f.year.selectedIndex].value+f.m
onth.options[f.month.selectedIndex].value+'.html'"

Thanks it worked

also for your first comment that's how I wanted the url to end up, so I took
the +'.html' bit off the end of your code to set in the correct format for
my needs.

Yes, of course. As I wrote that I was thinking that you were
generating a page name, rather than a page and a hash.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top