This week's book giveaway is in the
We're giving away four copies of
Node.js in Action
and have Mike Cantelon, Marc Harter, T.J. Holowaychuk and Nathan Rajlich on-line!
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Node.js in Action
this week in the
generate tag ids dynamically
Joined: Jan 12, 2013
Jan 12, 2013 05:46:38
I am new Please hellp !!!
can we use something like
y is a variable
out.println(<input type=/'text/' id=/'name"+y+"/'>);
out.println(<input type=/'text/' id=/'name<%=y%>/'>);
Please reply soon. Thanks in Advance
Joined: Nov 21, 2010
Jan 12, 2013 06:08:05
Please do you the code tag when putting any code.
Regarding the question.
out.println("<input type='text' name='t'"+y+ " id='t'"+y + "/>")
OR if using the " (double quotes to given the value to properties) then
out.println("<input type=\"text\" name=\"txt\""+y+ " id=\"txt\""+y + "/>")
Note the use of escape sequence \ (its not /)
If you are wrting in
then you can also use
<input type='text' name='txt<%=y %>' id='txt<%=y %>' />
SCJP 5.0 OCBCD 5.0(Formerly SCBCD)
Author and ninkuma
Joined: Jan 10, 2002
Jan 12, 2013 11:40:31
Why are you using out.println in the first place? That's really strange. The whole point of a JSP is
to have to create HTML in strings! Just put the HTML in template text.
Also, using Java scriptlets in JSPs is an obsolete practice from over 10 years ago! Time to modernize your skills with the JSTL and EL. Please see
this JspFaq entry
Asking smart questions
Books by Bear
I agree. Here's the link:
subject: generate tag ids dynamically
unable to get form Parameters
Getting elements by id
document.getElementById() not working
wrapping a function
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014