1

I have this SELECT element which i want to update the current url to URL&number=VALUE of selected item.

However, i can't figure how to catch the value.

<select name="prside" onchange="document.location.href = document.location.href + '&number=' + VALUE>
    <option>Annoncer pr. side</option>
    <option value="5">5</option>
    <option value="10">10</option>
    <option value="20>20</option>
    <option value="40">40</option>
</select>

4 Answers 4

1

check this out: http://jsfiddle.net/CdHPa/

you should use this.value instead of VALUE

besides at value 20 there is a missing "

Sign up to request clarification or add additional context in comments.

Comments

0

Try this code...

<select name="prside" onchange="document.location.href = document.location.href + '&number=' + this.value">
    <option>Annoncer pr. side</option>
    <option value="5">5</option>
    <option value="10">10</option>
    <option value="20>20</option>
    <option value="40">40</option>
</select>

Comments

0

replace this <select name="prside" onchange="document.location.href = document.location.href + '&number=' + VALUE> with <select name="prside" id="someid" onchange="somefunction();">

where

function somefunction(){
    var VALUE = document.getElementById("someid").value;
    document.location.href = document.location.href + '&number=' + VALUE
}

Comments

0

You can call a javascript function on the onchange event and then pass the value to the url like,

<select name="prside" id="prside" onchange="return changeURL();>
   <option>Annoncer pr. side</option>
   <option value="5">5</option>
   <option value="10">10</option>
   <option value="20>20</option>
   <option value="40">40</option>
</select>

<script type="text/javascript">
function changeURL(){
var value = document.getElementById("prside").value;
window.location.href = www.myurl.com?value="+value";}
</script>

Hope this helps, but please do check the syntaxes.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.