Reputation: 81
Seems pretty simple, but I can't find any documented examples. I want to create a basic HTML or PHP drop-down form that shows site links as the options. When user selects an option in the drop-down list, then the new link is opened in the browser. (Auto-submit). I'd prefer not to use a submit button, but would be nice to have the option in case the auto-submit does not work for the user. Here is what I have so far, and forgive my ignorance, but I just don't know the correct values. Looking for the most simple and short way to accomplish this with either HTML, Java or PHP. See below, I've just put ??? to represent the values that I am unsure of. I'm also not quite sure if onchange="this.form.submit(); is what I should be using. Thanks very much for any help on this. I'd appreciate if code suggestions are put into context so that newbies like me will be able to figure it out.
<form name="???" action="???" method="???">
<label for="???">Site Links</label>
<select id="???" name="???" onchange="this.form.submit();">
<option value="http://www.example.com/about.htm">About</option>
<option value="http://www.example.com/contact.htm">Contact</option>
<option value="http://www.example.com/products.htm">Products</option>
<option value="http://www.example.com/photos.htm">Photos</option>
<option value="http://www.example.com/prices.htm">Prices</option>
<option value="http://www.example.com/faq.htm">FAQ</option>
</select>
<button type="???">Submit Form</button>
</form>
Upvotes: 0
Views: 669
Reputation: 2924
Assuming that your select Id is "select1" (better than "???" to demonstrate):
$('#select1').change(function() {
window.location = $(this).val();
}):
Upvotes: 0
Reputation: 94131
$('option').click(function(){ location.href = $(this).val(); });
Upvotes: 0