Bookmark Topic Watch Topic
  • New Topic

index of option

 
Sudhir Pawar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Report post to moderator
please tell me jsp code to get index value of option list(drop down list)

i have created drop down list as follows
<select id="instance2" >
<option value="name">Item0</option>
<option value="name">Item1</option>
<option value="name">Item2</option>
</select>


now i want to get index value of selected item in variable then how can i do this??
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
Are you submitting the form where this select is to a servlet or to another JSP file ?
 
Sudhir Pawar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Report post to moderator
submitting form to current jsp file.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
You can access the value using the Expression Language (EL) : ${instance2}.
But you'll get the value, not the label. In your example, all options have the same value. You should give them different values.
 
Sudhir Pawar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Report post to moderator
but how to store index value in variable?
give me proper eg. with stntax.
Because i tried but shows ; expected error.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
But how to store index value in variable?

Which index ?

give me proper eg. with stntax.

It would be better if you could come up with a solution by yourself.

Because i tried but shows ; expected error.

Where ? Maybe you should post your JSP code here.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65217
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not post the same question more than once. I am closing this one so that any discussion can occur in the duplicate post.
 
    Bookmark Topic Watch Topic
  • New Topic