80
rated 0 times
[
86]
[
6]
/ answers: 1 / hits: 8366
/ 9 Years ago, mon, february 16, 2015, 12:00:00
How can I have my dropdown selected with an url parameter?
I found this:
Dropdown selected based on URL parameter - PHP or jQuery?
But it does not work for me. What am I doing wrong?
My url would be:
kontakt.php?Betreff=3
script:
var val = location.href.match(/[?&]Betreff=(.*?)[$&]/)[1]; // get params from URL
$('#Betreff').val(val); // assign URL param to select field
and:
<select class=mailstyle name=Betreff id=Betreff>
<option value=1>First</option>
<option value=2>Second</option>
<option value=3>Third</option>
</select>
More From » php