1.

Solve : submit button to act as link?

Answer»

Hi guys,

I have a drop down box via the tag and then a SUBMIT button next to it.

I want it so that if the drop-down shows "page 1" or something and then you hit "submit" it links to page 1. Same for "page 2" etc..

Is this possible, and how can I do it please!

Thank you for any replies posted!It is most definitely possible. And it's relatively simple. However, this sort of thing is typically done with PHP. If you would like, I [or another member] can explain how to do it. Or you can use a generator such as this one:
http://www.htmlbasix.com/dropmenu.shtml

(You may need to use Firefox to view that page.)You can also leave the submit button out and use the onChange functionAlso have a look at Dynamic Drive and JavaScript Kit. They have all the JavaScript codes you will ever need.I personally think this is much easier to do with PHP, but I guess we all have to what works best for us.I've known JavaScript for longer.... But PHP is propably easier. I've actually known JavaScript longer as well, but I found it MUCH easier to get into PHP. They're both great, of course, but I think I'm probably a little biased.Something tells me you should create an array, use the onChange function to CHANGE a value, and have the submit button GO to a different place depending on the value --matching the array data.

I don't KNOW javaScript, only actionScript.Quote from: GolemdS on August 18, 2008, 10:36:23 AM

Something tells me you should create an array, use the onChange function to change a value, and have the submit button go to a different place depending on the value --matching the array data.

I don't know javaScript, only actionScript.

Thanks for the INPUT, but it seems kop442000 hasn't visited for a while.I am a javascript learner. So I type all this code.
there is 4 files :page1.htm,page2.htm,page3.htm,and index.htm ,please place them in the same forlder.

page1.htm:
Code: [Select]page1 haha...page2.htm:
Code: [Select]page2 herepage3.htm:
Code: [Select]this is page3index.htm:
Code: [Select]<html>
<head>
<title>page changer</title>
</head>
<body>
<iframe name="target_window" src="page2.htm">
</iframe>
<select name="sel"
onchange="document.all.target_window.src=sel.options(sel.selectedIndex).value;" >
<option value="page1.htm">page1</option>
<option value="page2.htm" selected>page2</option>
<option value="page3.htm">page3</option>
</select>
<br>
<input type="button"
onclick="window.open(document.all.target_window.src,'_blank');"
name="btn" value="View this page in new window"/>
</body>
</html>
I display new page in iframe!

first I forgot to add the button


Discussion

No Comment Found