SELECCIONE el valor en Javascript

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>

preguntado el 28 de agosto de 12 a las 13:08

4 Respuestas

mira esto: http://jsfiddle.net/CdHPa/

you should use this.value instead of VALUE

besides at value 20 there is a missing "

Respondido 28 ago 12, 13:08

Prueba este código ...

<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>

Respondido 28 ago 12, 13:08

reemplazar esto <select name="prside" onchange="document.location.href = document.location.href + '&number=' + VALUE> con <select name="prside" id="someid" onchange="somefunction();">

sin que importe

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

Respondido 28 ago 12, 13:08

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.

Respondido 28 ago 12, 13:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.