Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Variable Syntax

 
Alice Huber
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I wish to give name attribute of <input> tag as variable depending on value of i. Kindly guide for the syntax.



Thanks
 
Tim Moores
Bartender
Posts: 2891
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to add double quotes around +varfld+ .
 
Alice Huber
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim,

Double quotes around +varfld+ does not resolve the issue.



Html code generated out of above code in Servlet is as below -



 
Tim Moores
Bartender
Posts: 2891
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I said "double quotes", not "escaped double quotes" - which renders them inoperable.
 
Alice Huber
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim. Below code worked out.



Html Ouput is :
 
Rob Spoor
Sheriff
Pie
Posts: 20605
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Slightly better is escaped double quotes and non-escaped double quotes:
The output will then also have quotes around the name attribute value.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic