javascript - Would like to pass variable value to same jsp -


am trying retrieve variable value passed list jsp code in same page. here sample code:

<form> <table> <tr> <td>heading : </td> <td> <select id="heading" name="program" onchange="return setvalue();"/> <option value="">new</option> <!--database connection , retreving value , displaying in option tag --> <option value="<%=rs.getstring(1)%>"><%=rs.getstring(1)%></option> </select> </td> </tr> </table> </html> 

and have written script code can pick value selected in list box , store variable, code:

<script type="text/javascript">     function setvalue(){         alert("inside method");         alert(document.getelementbyid("heading").value);         var heading=document.getelementbyid("heading").value;         alert(heading);         //window.location.replace("addmenuitem.jsp?menumain="+menumain);             return true; } </script> 

it displaying value. need value displayed in scriptlet variable.

provide me suggestions go ahead.

thank in advance.

there work around add hidden field

  <input id="hiddenparam" name="hiddenparam" type="hidden" />  

then

var heading=document.getelementbyid("heading").value;     document.getelementbyid("heading").value=heading; 

later other parameter can access request.getparameter("heading"); in server side if trying send parameter using query string


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -