This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes form does not validate in my selection box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "form does not validate in my selection box " Watch "form does not validate in my selection box " New topic
Author

form does not validate in my selection box

dela cruz juan
Greenhorn

Joined: Nov 21, 2012
Posts: 13
Hi Java Guru's

Just want to ask some help on the below code, seems like when I try to select multiple items on the select topic 3 the form only validates a single item

Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

I think what you have to do to get all the items selected in the multi select list is to pass the select item itself to the method, then iterate over all the items, check to see if it is selected and if it is do what is appropriate.


Steve
dela cruz juan
Greenhorn

Joined: Nov 21, 2012
Posts: 13
Steve Luke wrote:I think what you have to do to get all the items selected in the multi select list is to pass the select item itself to the method, then iterate over all the items, check to see if it is selected and if it is do what is appropriate.


Hi,
can you help me with these actually I only copied this code from some sites and did some research on understanding the java as well, going to my problem, the code really validates on what I choose on the selection boxes, the only only thing is the last selection box :



when I choose multiple items it didn't validate all, only one.
you can also try it
<Math> - <basic_math> - <addition> +<2 items>
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Please don't add really long lines to your code tags, it breaks the format...

understanding the java as well

Nothing you posted is Java code. It is JavaScript code, which is a different programming language. It is important to understand that.

As mentioned, you have to pass the select object or the list of options in the Select. Then iterate over each option, check if it is selected, and if it is do the work. See this page on W3Schools for methods available on the Select object, and this page for those available on the Option objects.
 
 
subject: form does not validate in my selection box