If by "previous" you mean on a previous page, which has been submitted to a servlet/JSP, then it's fairly straightforward. If you mean another listbox on the same page then it's not a simple problem. You might find the code examples at the following old thread helpful.
well i am assuming you mean a listbox in html and from "previous listbox" you mean a listbox in the previous (not current) page...in that case its pretty simple simply either use a jsp variable in html to set the value of the list box for eg <form name="myform"> <select name="myselect" rows=1> <option><%=jspVar0%></option> <option><%=jspVar2%></option> ........ .... </select> </form> or use javascript to add or edit items in a list box in the current page for eg <script> document.myform.myselect.options[0].text="sometext"(or <%=jspVar%> </script>
I would frame my query in a better way I am using Javabeans say for example, <jsp:useBean id="formHandler" class="foo.FormBean" scope="request"> <jsp:setProperty name="formHandler" property="*"/> </jsp:useBean> Now i need to set the getter/setter methods, Here I access a textbox like this public String getFirstName() { return firstName; } //The Setter method public void setFirstName(String fname) { firstName =fname; } This particular piece of Info I retain to use in later pages, Similarly How would i go about ListBoxes which has fixed values and once selected by user is retained/Used in later pages. Warm Regards to all
You can try this may be. The listboxes LB1 & LB2 are in lets say demo.jsp. And u want to populate LB2 depending on the value in LB1. In the OnChange event handler for LB1 submit the form to demo.jsp itself by sending the selected value as data to the jsp. Then u can use the getparameter method within demo.jsp to populate the LB2 dynamically. The whole point is about the jsp calling itself. I did a similar code recently and it worked perfect. Rajesh
In the JavaBean, I would use a string array to store the values of the dropdown listbox. In next page, you can retrieve the string array to populate the dropdown listbox
Please note that The Java Ranch has a naming policy, described here and "bredan" is not a valid name. Please choose one which meets the requirements. Thanks.
Post by:autobot
I don't always make ads but when I do they're tiny
a bit of art, as a gift, the permaculture playing cards