Reputation: 4974
I want the user to click the select box and when have selected any option redirect to index.php?id={variableId}&itemId={secondVariableId}
Like:
<select name="select">
<option value="id=1&itemId=2">One</option>
<option value="id=1&itemId=3">One</option>
<option value="id=2&itemId=1">One</option>
[...]
</select>
But, I can not imagine where to start
Upvotes: 0
Views: 196
Reputation: 34107
Hiya this might help: sample demo http://jsfiddle.net/5NCQg/34/
Jquery COde
$(document).ready(function () {
var url = "http://forum.jquery.com?" // in this case your URL
$("select#foobar").change(function() {
alert('change');
url= url + $(this).val();
alert(url);
window.location = url;
});
});
HTML
<form id="temp1">
<select id="foobar">
<option value="nothing"> --select-- </option>
<option value="id=foo&itemid=bar"> click1 </option>
<option value="id=foo&itemid=bar"> click2 </option>
</select>
</form>
CHeers!
Upvotes: 1
Reputation: 189
What you can do is add the option multiple=yes to your select tag. When this is posted back, it will be in an array. Here's a good sample that you can test with: http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select_multiple
Upvotes: 1
Reputation: 3167
I think this is what you want (if i'm understanding correctly and assuming jquery is being used).
$("select").on("change", function() {
window.location = 'index.php?' + $(this).val();
});
Upvotes: 1
Reputation: 1533
You can use the "onChange()" function, but does not work properly in some versions of IE, as I remember.
Upvotes: 1
Reputation: 20235
<select name="select" onchange="window.location='index.php?' + this.value;">
<option value="default">- select -</option>
<option value="id=1&itemId=2">One</option>
<option value="id=1&itemId=3">One</option>
<option value="id=2&itemId=1">One</option>
[...]
</select>
Upvotes: 2