This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JSP and the fly likes Javascript var inside a EL List's index Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Javascript var inside a EL List Watch "Javascript var inside a EL List New topic

Javascript var inside a EL List's index

Chetan Pandey
Ranch Hand

Joined: Aug 01, 2005
Posts: 31
I have the folowing requirement:




Instead of the XX above I want to use the javascript 'index' variable.

I have tried <c:set var="ind1">index</c:set>


and several other ways. to no avail including scriptlets

any ideas.


D. Ogranos
Ranch Hand

Joined: Feb 02, 2009
Posts: 214
That is not going to work. Your function func() is javascript, which is executed in the client (the browser). The EL expression ${requestScope...} is executed on the server, before the page even arrives at the client.

If you want to choose something from that list (which is on the server) based on a user action in the client, you will have to make another request to the server (either a form submit, or an AJAX request).

OR, you could write all the values in the list on the page, as javascript instructions, and then have your function select from that.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60050

Please read this article to understand JSP and why you cannot do it that way.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
wood burning stoves
subject: Javascript var inside a EL List's index
Similar Threads
Regarding xml Data
mock exam jstl core iteration custom tags
set bean property with request attribut
page 446 target value as array?
Problem with JSTL c:out tag