Web Hosting Talk







View Full Version : Need help with a form please, very easy but I dont know how


lexington
10-17-2004, 08:16 AM
Hello, I want to create a drop down menu form so that when someone selects an option and clicks go, they are directed to that page. I have created a form below but it is only used as a demo to show you what I am trying to do, but I do not know what info to enter into this form to make it work.

<form action="">
<b>Text:</b>
<select name="test">
<option value="blah1">test1</option>
<option value="blah2">test2</option>
<option value="blah2">test3 </option>
</select>
<input type="submit" value="go" name="submit">
</form>

So let's say someone selects the option test2 and hits the go button, they will be taken to test2.htm. That is what I am trying to do, make the options direct to the page of my choice. Could anyone please provide the code necessary to accomplish this? Thanks

Dryice
10-17-2004, 11:37 AM
<script language='javascript'>
function gotourl()
{
location.href = document.selection.theselector.value
}</script>

<form name='selection'>
<select name='theselector'>
<option value='page1.html'>Page 1
<option value='page2.html'>Page 2
<option value='page3.html'>Page 3</select>
<input type='button' value =' Go' onClick='gotourl()'>
</form>

WebDesignGold
10-17-2004, 11:43 AM
You forgot "OnClick".

<form name="jump">
<select name="menu">
<option value="test1.html">blah1</option>
<option value="test2.html">blah2</option>
<option value="test3.html">blah3</option>
</select>
<input type="button" onClick="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;"

value="GO">
</form>

lexington
10-17-2004, 12:59 PM
Thanks guys

lexington
10-17-2004, 01:03 PM
Sorry, but how can I make it so that their is no need for the GO button and when the user selects an option it automatically directs them?

Dryice
10-17-2004, 01:15 PM
<SCRIPT>
function getSelect(s) {
return s.options[s.selectedIndex].value
}
</SCRIPT>
<FORM>
<SELECT NAME="list" SIZE=1 OnChange="location=getSelect(this)">
<OPTION value="#"> Jump to...
<OPTION value="page1.html"> Page 1
<OPTION value="page2.html"> Page 2
<OPTION value="page3.html"> Page 3
</SELECT>
</FORM>

lexington
10-17-2004, 01:18 PM
Man where do you guys learn this lol. Thanks

lexington
10-17-2004, 01:27 PM
Ok last question I promise :) How can I change the background color and text color of the form?

Dryice
10-17-2004, 01:45 PM
<SCRIPT>
function getSelect(s) {
return s.options[s.selectedIndex].value
}
</SCRIPT>
<FORM>
<SELECT style="background-color: #000000; font: arial; color: #fefefe" NAME="list" SIZE=1 onChange="location=getSelect(this)">
<OPTION value="#"> Jump to...
<OPTION value="page1.html"> Page 1
<OPTION value="page2.html"> Page 2
<OPTION value="page3.html"> Page 3
</SELECT>
</FORM>
#000000 is black, #fefefe is white
change to whatever

lexington
10-17-2004, 08:20 PM
Thanks alot

TLowe
10-18-2004, 02:23 PM
Nice Scripts there guys :)