Jump to content
  • Advertisement
Sign in to follow this  
namingway

[web] help using forms

This topic is 4160 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
The simplest method is:

<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" />

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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'?

Share this post


Link to post
Share on other sites
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" />

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!