when the button is clicked, sub(btn, form) is invoked in which " form.submit();" is invoked.
And also in the JSP page I am using below hidden input:
<input type="hidden" name="index" value="<%=request.getParameter("index")%>">
When the form loaded oafter submit, the another java script function init() is called and inwhich I want to use the value of the index variable, so that list box selection is preserved. But that index variable is coming out as undefined in the init method.
Please help me where I am going wrong.
Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.
You can go back and change your post to add code tags by clicking the button on your post.
But more to the point, if all you want to do is to set the select element back to its submitted value, you don't need the index at all, so passing it around is useless.
Please verify if that's what your purpose is or not.
Bhanu S Chatta
Joined: Apr 15, 2006
That is setting a variable named index, you are not setting the value of your hidden field.
Why are you not setting the initial value from the server to begin with?
In the form object, while debugging I am not getting the list items or the item that is selected.