• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

generate tag ids dynamically

 
Utkarsh Jauhari
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new Please hellp !!!

can we use something like
y is a variable
out.println(<input type=/'text/' id=/'name"+y+"/'>);
or
out.println(<input type=/'text/' id=/'name<%=y%>/'>);

Actually i want to generate tag id's dynamically for form inputs(which are generating dynamically too) for further value retrieval through javascript.
as

var temp=document.getElementById("name1").value;
var temp1=document.getElementById(name2).value;

Please reply soon. Thanks in Advance
 
Vijay Vishwa
Ranch Hand
Posts: 40
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Utkarsh,

Please do you the code tag when putting any code.
Regarding the question.



OR if using the " (double quotes to given the value to properties) then


Note the use of escape sequence \ (its not /)

If you are wrting in JSP then you can also use



 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using out.println in the first place? That's really strange. The whole point of a JSP is not 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic