Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid Character Error

Status
Not open for further replies.

Mighty

Programmer
Feb 22, 2001
1,682
US
Guys,

I have the following line in a JS function. I know that the problem has something to do with all the single and double quotes but I have no idea what it is and it's doing my head in. Here is the code:

strHTML='<TD ALIGN = &quot;CENTER&quot;><INPUT TYPE = &quot;TEXT&quot; SIZE=&quot;10&quot; NAME = &quot;' + CreateField(&quot;DueDate&quot;) + '&quot; VALUE = &quot;&quot; onFocus=&quot;this.blur();javascript:show_calendar(\'ProdForm.' + CreateField(&quot;DueDate&quot;) + ''\);&quot;></TD></TR>';
Mise Le Meas,

Mighty :)
 
Can I not have single quotes within single quotes??

iza,

Can you please do me a favour and have a look at another post that where you gave advice to Nickster. I followed your advice but have a little problem. The thread is: &quot;Using JS to generate Form inputs&quot;.

Thanks in advance.

Mise Le Meas,

Mighty :)
 
If you initialize the string with double quotes then when ever inside the string (ie not broken out of it to call functions or variables) use the escape code to produces double-quotes in your string.
ie
strHTML = &quot;<TD ALIGN=\&quot;CENTER\&quot;><INPUT TYPE=\&quot;TEXT\&quot; SIZE=\&quot;10\&quot; NAME=\&quot;&quot; + CreateField(&quot;DueDate&quot;) + &quot;\&quot; VALUE = \&quot;\&quot; onFocus=\&quot;this.blur(); javascript:show_calender(\&quot;ProdForm.&quot; + CreateField(&quot;DueDate&quot;) + &quot;\&quot;);\&quot;></TD></TR>&quot;;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top