javascript - how to retain drop down selected values after form submitted? -
how retain drop down selected values after form submitted? have form submit via onchange
problem when select value drop down form submitted drop down values struck on select option
javascript
<script> function getdropdownvalue(){ var e = document.getelementbyid("size"); var struser = e.options[e.selectedindex].value; } </script>
drop down select
<form name="size" id="size"> <select style="background-color:#ccc" name="size[]" id="size" onchange="this.form.submit();getdropdownvalue();" > <option value="">select</option> <option value="small">small</option> <option value="medium">medium</option> <option value="large">large</option> <option value="xl">xl</option> </select></form>
you want run getdropdownvalue();
before submitting form:
<select style="background-color:#ccc" name="size[]" id="size" onchange="getdropdownvalue();this.form.submit();" >
to make sure drop-down value retained, submit form invisible iframe
. allows form submitted without refreshing page:
<form target="invisible">...</form> <iframe name="invisible" style="display: none"></iframe>
Comments
Post a Comment