Results 1 to 2 of 2
  1. #1
    _Nikkiz_ is offline Member
    Join Date
    Jul 2013
    Posts
    2
    Rep Power
    0

    Default 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.
    Java Code:
     <html>
    <body>
    <form>
    <input type="textbox" name="billingaddress">
    <input type="textbox" name="billingcity">
    <input type="checkbox" name="chksameaddress" value="true">
    <%
    Boolean sameaddress = Boolean.parseBoolean( request.getParameter("chksameaddress")
    if (sameaddress)
    {
        //not sure what to do here
    }
    %>
    <input type="textbox" name="installationaddress">
    <input type="textbox" name="installationcity"
    </form>
    </body>
    </html>
    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?

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,098
    Rep Power
    6

    Default Re: JSP autofill textbox

    Its input type="text", not input type="textbox".

    You have a few basic options, all javascript so not really for this forum but I can give you a nudge in the right direction.

    1) put the text fields and fill them, but make them visible/invisible through CSS based on the checkbox checked state. This will require putting an onChange javascript event listener on the checkbox.
    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.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. How I can draw on textbox
    By iraqy2010 in forum CLDC and MIDP
    Replies: 0
    Last Post: 06-19-2011, 05:48 PM
  2. How to set value to a TextBox
    By kishan in forum JavaServer Faces (JSF)
    Replies: 3
    Last Post: 06-29-2010, 02:46 PM
  3. Urgent Please help :Autofill textbox using AJAX
    By mnprakash in forum Advanced Java
    Replies: 0
    Last Post: 01-05-2009, 08:31 AM
  4. Autofill?
    By Atashi in forum NetBeans
    Replies: 0
    Last Post: 11-27-2008, 09:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •