[RESOLVED] Select menus nad navigation
Hi,
Venturing into the world of web programming.
i am trying to use a "Select menu" to navagate to a local html page after a selction has been made, i tried searching and came up with nothing.
HTML Code:
<label for="select-choice-0" class="select">Select Customer:</label>
<select name="select-choice-0" id="select-choice-1">
<option value=""><a href="details.html">bj builders</option>
<option value="">walkers</option>
<option value="">hogans building</option>
<option value="">QLD Electrical</option>
</select>
this is the line i have been trying to get the page link to work in.
HTML Code:
<option value=""><a href="details.html">bj builders</option>
thx
-toe
Re: Select menus nad navigation
You have forgot to close the anchor tag.
That line should be like this:
Code:
<option value=""><a href="details.html">bj builders</a></option>
:wave:
Re: Select menus nad navigation
Re: Select menus nad navigation
oh! I didn't see that you were using a dropdown box. So, when you select an item, you want to open it's corresponding link. Isn't it ?
Here's a sample piece of code:
HTML:
html Code:
<select name="gotoLinks" id="gotoLinks">
<option value="http://www.google.com?q=kerala">Kerala</option>
<option value="http://www.google.com?q=india">India</option>
<option value="http://www.google.com?q=us">US</option>
<option value="http://www.google.com?q=canada">Canada</option>
</select>
jQuery code:
Code:
$(document).ready(function(){
// when the user changes the combobox value
$('#gotoLinks').change(function(){
var toURL = $('#gotoLinks :selected').val(); // get the selected items URL
alert(toURL); // display the selected item's URL
window.location = toURL; // goto that URL.
});
});
Here's the fiddle: http://jsfiddle.net/meNYe/
:wave:
Re: Select menus nad navigation
thx, so i need the full url it seems?
Re: Select menus nad navigation
Quote:
Originally Posted by
toecutter
thx, so i need the full url it seems?
Full URL needs to be passed to window.location.
If you want to avoid inserting full urls, use a global var that points to your domain:
Code:
var myDomain = "http://www.google.com/"
So, for the window.location, append it with the page selected from the select box:
Code:
window.location = myDomain + gotoURL; //where gotoURL contains "index.html"
:wave:
Re: Select menus nad navigation
excellent,thx
for some reason i am unable to rate you
Re: Select menus nad navigation
Quote:
Originally Posted by
toecutter
excellent,thx
for some reason i am unable to rate you
:)
:wave: