• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pass Sciptlet to jsp

 
Mamata Chaudhari
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hii..
I want to use a scriplet variable in javascript.
i used
<%! int i;>
<% i=0; %>
<input type="text" id="itemValue" onchange=changeValue('<%=i%>')>

it works fine if i give alert(i) in
changeValue() function.
Otherwise it gives error i is undefined.
Please help me. I don't want to bother user by increasing one user click.
Please help what is the reason ???

i m using struts 1.2

 
Albareto McKenzie
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you copy-pasted directly that code? This <%! int i;> cannot be compiling...

With so few code is difficult to help you, just with this it should work (as far as you close properly the scriptlet tag I mentieoned before.
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mamata,
Welcome to javaranch.

can you post your javascript function also?
signature of that should be


then it will work.

and use code tags to post code.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mamata Chaudhari wrote:I want to use a scriplet variable in javascript.


It is poor practise . Use EL
 
Mamata Chaudhari
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply
but that textbox is in logic:iterate.
I want to identify in javascript.
I used indexed property of logic:iterate.
but not working.
How can i use EL??
I don't have any idea.

 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I suppose this has become a Struts question. Anyways, I don't know much about Struts 1.2, but looking at this reference I think you can use indexId attribute to specify a name for a bean that will contain the index of the current iteration which you can use instead of the scripting (you also mentioned that you used indexed property of iterate tag, maybe you made a typo or something)...
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mamata,

Please post code you tried so we will better understand problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic