JSP autofill textbox
When I fill in a 2 textboxes, I want two other textboxes to be automatically filled with the same thing if I check a checkbox.
thats just the basic framework. But I'm not sure how to get this to work. Any suggestions? or can you point me in the right direction?
<input type="textbox" name="billingaddress">
<input type="textbox" name="billingcity">
<input type="checkbox" name="chksameaddress" value="true">
Boolean sameaddress = Boolean.parseBoolean( request.getParameter("chksameaddress")
//not sure what to do here
<input type="textbox" name="installationaddress">
<input type="textbox" name="installationcity"
Re: JSP autofill textbox
Its input type="text", not input type="textbox".
2) use Ajax logic (for example: JQuery) to fetch the address details from the server side when the checkbox is checked. That's more advanced material since you will need to create a servlet to actually be able to retrieve the data through an Ajax HTTP request.
3) dumb non-ajax way done before "web 2.0": upon changing the checkbox let the page submit to itself so you can rebuild the page with the text fields either filled or not
And of course you always have the option of not using JSPs anymore where you have to do everything yourself and in stead use an Ajax enabled framework such as Apache Wicket to make these kind of tasks a whole lot easier, once you are over the hump of learning the framework itself.