rejetto forum

javascript error

0 Members and 1 Guest are viewing this topic.

Offline SpiderPig902

  • Occasional poster
  • *
    • Posts: 24
    • View Profile
I am racking my brain trying to figure out this java script error. Every time my page loads i get a "Unterminated String Constant".
here is where the problem is. If i remove this form statement the error goes away:
<form action="/" method="get" style="padding:5px 0px 0px;margin:0px" name="simpleSearch"><input type="text" name="search" value="{.$search-data.}" onclick="if(this.value=='{.$search-data.}')this.value=''" style="width:100px"/> <input type="submit" value="Search"></form>


The actual line is the input box. if i remove that the error goes away also.

Does anyone know java enough to see what the problem is?


The section is "[FolderOptions]" in the Terayon" template.
Thanks in advance.

Tony


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
i guess you get the problem when putting a single-quote ' in the searching field.
right?


Offline TSG

  • Moderator
  • Tireless poster
  • *****
    • Posts: 1935
    • View Profile
    • RAWR-Designs
I tested this, it wont do it for me...

Even with your theory with quotations rejetto.

What browser are you using and maybe provide a link (so long as there is nothing suss there) for the forum to test.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
i guess your browser is just not displaying you the error.
it's easy to understand: literal strings in javascript must be escaped if you get as data the same character you are using as delimiter (single or double quotes).
if you have a value that's "a'b"
then this line
this.value=='{.$search-data.}'
will become
this.value=='a'b'
that's clearly a syntax error for the javascript interpreter.
i guess this may solve {.replace|'|\'|$1.}


i just noticed a similar problem in the default template. it's an html error on this line
value="{.?search.}"
that i can fix by {.replace|"|&quot;|$1.}


Offline SpiderPig902

  • Occasional poster
  • *
    • Posts: 24
    • View Profile
hi sorry for the delay in this. where would i put that line "{.replace|"|&quot;|$1.}". I cant replace the search string so im not sure where to replace it.

SP


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
try this
this.value=='{.replace|'|\'|{.$search-data.}.}'


Offline TSG

  • Moderator
  • Tireless poster
  • *****
    • Posts: 1935
    • View Profile
    • RAWR-Designs
I will include a fix in the small update I am making to the templates to address some issues.
« Last Edit: June 12, 2010, 01:27:18 PM by TSG »