File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes select tag doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "select tag doubt" Watch "select tag doubt" New topic
Author

select tag doubt

Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
I have a select tag which contains a few elements viz...




I click on it and I could see all the items ,however, I cannot select the first element of the tag...why is that so?

and also if I select an item,next time I cannot select the same thing again!

what could be the change?
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

> and < are used to start and end a tag name. So they have a special meaning. Try using &gt; instead of > and &lt; instead of < inside your <option> tags...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
I Roger that! but my issue still persists.Even if i have a,b,c,d,e as my drop down values,I can't select value 'a ' meaning (cant listen it! )where as the other values can be selected(I have id's for all these where i use in Javascript to listen a selected value on select)
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

I have id's for all these where i use in Javascript to listen a selected value on select

So the sample code which you showed us is not what you are using?? The select tag you've shown here is disabled. If you are calling some javascript code on the click event of an option tag, that also might create some problem...
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Yes I use that .In fact I have 4 select tags.But it's just not listening the first item and works fine with the rest of items!
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Pradeep Adibatla wrote:Yes I use that ....it's just not listening the first item....

I'm not sure what's this supposed to mean. What I'm asking is, just post the exact code which you are using (including any javascript code), don't post any dummy code which is similar to the actual code...
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
The onchange event does NOT fire when the option does NOT change.
Use onblur or add a default option to the top of the list that says pick, choice, select, etc.

Eric
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Eric Pascarello wrote:The onchange event does NOT fire when the option does NOT change.
Use onblur or add a default option to the top of the list that says pick, choice, select, etc.

Eric


..Or stop using them. The SELECT element, when used for selecting single items, is one of the worst HTML controls, in my opinion. A autocomplete widget is much better and you can populate them both locally or using ajax to grab the data from the server. Much better user experience, as far as I'm concerned. (Yes Eric, I'm aware that the HTML SELECT tag is probably more accessibility friendly).


GenRocket - Experts at Building Test Data
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
long time, but would still go ahead!!!

@Gregg

You mean to say s:autocompleter ??

Actually I need to populate 2 arrayLists of objects in 2 dropdowns...

and based on the value selected in list 1, I need to populate values for the second dropdown(pending)

With select tag I can't select the 1st value that is populated. should I use s:autocompleter ??


Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
As already stated: Onchange does not fire when you reslect the same thing.

Either add a default option to the top of the list or use onblur

Eric
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
This is the one i have...



onBlur doesn't do anything!

how to add default to this???

Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Add an <option> tag manually above your iterator?

Eric
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
what would that do? I don't know the values to set a default value...

you meant this isn't it??



but i don't know that values...

The situation is like this...

lets say i have C1,C2,C3...

Initially i can't select the first value(C1).So i select something else(C2).Now I can't select the value that I previously selected(C2).


As you said onChange has a problem with this and the same with onBlur too!

What is the main reason and solution? You expert opinion and explanation would give great clarity!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
onblur does not have an issue when you reselect the same value

The onblur event fires when focus is removed from the element.

Eric
 
 
subject: select tag doubt
 
Similar Threads
JSP select with multiple options
How to do a Tool tip in select drop-down?
how to use select tag using struts
JSP Newbie - Dynamic ComboBox
Mixing JSP and Scriptlets throws compilation errors