Results 1 to 6 of 6

Thread: HTML/Java

  1. #1
    Bomber_Will is offline Member
    Join Date
    Nov 2008
    Posts
    40
    Rep Power
    0

    Default HTML/Java

    Not sure which section to post this on.

    I have 2 choice boxes. List 1 has option A and B and the List 2 is empty. Is there a way by using HTML alone or with the help of Java to make it so that if a person picks option A from the List 1, it would populate List 2 with something and if option B is picked, list 2 would be populated with something completely different?

    Is there a way for these options to display a value into a text box and update itself everytime a new option is picked from any of the Lists?

    Thanks.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,574
    Rep Power
    12

    Default

    Is there a way by using HTML alone or with the help of Java
    Are these "choice boxes" an HTML construct? If so you may be helped by JavaScript which can listen for selections on the first widget and respond by populating the second.

    But JavaScript != Java. JavaRanch have a "client side" forum.
    Last edited by pbrockway2; 03-13-2009 at 06:59 AM. Reason: added link

  3. #3
    Bomber_Will is offline Member
    Join Date
    Nov 2008
    Posts
    40
    Rep Power
    0

    Default

    Yes the boxes are an html construct. I have literally no idea about Javascript though. I'll see that link you gave though.

    Edit: If it can't be done through Java, thats ok. I just wanted to see if it was possible.
    Last edited by Bomber_Will; 03-13-2009 at 10:54 PM.

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,574
    Rep Power
    12

    Default

    Just posting to say yes, "it" can be done for certain values of "it".

    In particular you could write an applet (some instance of JApplet) with a panel containing a couple of JList widgets. You use addListSelectionListener() on the first to detect selections and have it respond by populating the second (eg with setListData()).

    Details in the How to Use Lists section of Sun's Tutorial. But, before you race off to write an applet, consider whether it will do what you want. You haven't actually said what you are going to do with the contents of the second list - the chances are that you want HTML and that you want it to be dynamic, in which case investigate JavaScript.

  5. #5
    Bomber_Will is offline Member
    Join Date
    Nov 2008
    Posts
    40
    Rep Power
    0

    Default

    Yes I know this is late >_>

    Thanks for the response. I'll look into setListData. I want to avoid JS since I have no idea about it.

  6. #6
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,574
    Rep Power
    12

    Default

    There should be enough in the "How to Use Lists" link to get you started. Post back if you have specific problems with your code.

Similar Threads

  1. Using HTML in java
    By hitmen in forum AWT / Swing
    Replies: 3
    Last Post: 02-26-2009, 06:58 AM
  2. Java String to html var
    By tman563 in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 02-17-2009, 03:59 PM
  3. Java + html
    By GabWit in forum New To Java
    Replies: 4
    Last Post: 01-25-2009, 04:58 AM
  4. How can I include a html file in html textarea?
    By surya_dks in forum New To Java
    Replies: 2
    Last Post: 10-04-2008, 08:20 AM
  5. Java Applet HTML
    By ownlol in forum Java Applets
    Replies: 4
    Last Post: 07-21-2008, 03:59 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
  •