Results 1 to 2 of 2
  1. #1
    barney is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    Default Help with dropdown list

    Hi, My requirement is that i have a radio button fail.after selecting data I have to select the reason also using the dropdown list. If the reason is not selected an error should be thrown. How to accomplish this in java.can anyone please help.

    Thanks.

  2. #2
    zoe
    zoe is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    Default

    There are many ways you could do this, some more difficult than others. I will list a couple of ideas, but depending on how your code has been written, they might not fit in.
    1) You could set the first value in the combo box to be "none", then you could obtain the value from the combo box and check that the value is not equal to "none" i.e. if(!ComboValue.compareTo("none")) //something like that.
    Java Code:
    {
    }
    else
    {
    System.out.println.........please select reason....(whatever)
    }
    2)The other way you could do this, would be to have a boolean global variable called "reason"(this is a bad name) set to false. When the check box is then used, inside the combobox handler set "reason" to true, then you can check the status of "reason". But remember to set it back to false again.

    With both of these examples i am assuming you have a JButton that you press after the fail radio button is pressed to submit the reason. These are both very simple examples. But they will both work.

Similar Threads

  1. Replies: 1
    Last Post: 05-01-2008, 04:19 PM
  2. getting values from database in dropdown
    By aa74 in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 04-21-2008, 11:00 PM
  3. Servlet with a Form/Dropdown
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-16-2008, 11:24 AM
  4. list
    By Zensai in forum New To Java
    Replies: 3
    Last Post: 11-20-2007, 08:22 AM
  5. How to get the max value from a list
    By osval in forum New To Java
    Replies: 1
    Last Post: 07-30-2007, 06:43 PM

Posting Permissions

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