Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

select tag doubt

 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9519
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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...
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9519
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9519
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the one i have...



onBlur doesn't do anything!

how to add default to this???

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add an <option> tag manually above your iterator?

Eric
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
onblur does not have an issue when you reselect the same value

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

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic