javascript - Select and hidden -


i have simple select several options. have hidden input.

i want valorize hidden input selected option.

so if:

    <select id="type" name="type">         <option value=""><fmt:message key="select.value" bundle="${g}" /></option>         <option value="0"><fmt:message key="intermediary.document.attachment.logo" bundle="${i}" /></option>         <option select="selected" value="riskassess"><fmt:message key="intermediary.document.attachment.riskassess" bundle="${i}" /></option>    </select>  

i want this:

<input type="hidden" id="type" name="type" value="advpf3" />  

someone can me? thx.

if have in plain javascript,

var e = document.getelementbyid("selectid");  e.addeventlistener("change",function(){     //get selected value     var val = e.value;     //set value input     document.getelementbyid("type").value = val; }); 

if have jquery in place then,

$("#selectid").change(function(){    var value = $(this).val();    $('#type').val(x); }); 

do note cannot give same id (now type) both select , input


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -