[web] help using forms
I am setting up a website where at the top a list menu containing some different categories are, next to it is a button that says 'Go'. I'd like to know how you set it up so that what ever is selected in the list menu go will send you to that page e.g. If C was selected it will take you to a page with C tutorials.
The simplest method is:
If you also want it to go automatically, change the select to look like:
<select id="menu"> <option value="/page1.html">Page 1</option> <option value="/page2.html">Page 2</option></select><input type="button" value="Go" onclick="if (document.getElementById('menu').value) location.href=document.getElementById('menu').value" />
If you also want it to go automatically, change the select to look like:
<select id="menu" onchange="if (this.value) location.href=this.value" />
You can also do a regular HTTP POST to the server and then do a 301 redirect to the correct URL. That way you do not need to mess with javascript at all (which is better for some browsers).
Quote:Original post by konForce
If you also want it to go automatically, change the select to look like:
<select id="menu" onchange="if (this.value) location.href=this.value" />
With this method, how do I get the page to open up in 'mainFrame'?
You're using frames? Ugh... don't...
But to answer your question, it would be something like:
<select id="menu" onchange="if (this.value) windows.parent.mainFrame.location.href=this.value" />
But to answer your question, it would be something like:
<select id="menu" onchange="if (this.value) windows.parent.mainFrame.location.href=this.value" />
Hey what's wrong with frames? I know plenty of sites that use them.
Also its not loading anymore at all.
[Edited by - namingway on June 2, 2007 6:52:42 AM]
Also its not loading anymore at all.
[Edited by - namingway on June 2, 2007 6:52:42 AM]
Quote:Original post by namingway
Also its not loading anymore at all.
I said it's something like that. I didn't test it. I guess it's window.parent, not windows.parent.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement