Page 1 of 1

javascript in form gives smarty error

Posted: Thu Nov 29, 2007 11:47 pm
by gajones76
I have a form on the page and I'm trying to use the following code to make the text "enter your email" disappear when the form field is clicked:

Code: Select all

<input name="email" id="email" value="enter your email" size="20" onfocus="if(this.value=='enter your email') {this.value=''}" type="text" />
Whether i put the code directly into the page or in a content block the result is similar:

string(131) "Smarty error: [in globalcontent:mailinglist line 8]: syntax error: unrecognized tag: this.value='' (Smarty_Compiler.class.php, line 446)" string(119) "Smarty error: [in globalcontent:mailinglist  line 8]: syntax error: unrecognized tag '' (Smarty_Compiler.class.php, line 590)"

Subsequent reloads of the page remove the error, but also strip out the offfending code from the form:

{ this.value=''; }"

Is there any way to get this to work?

thanks

Gareth

Re: javascript in form gives smarty error

Posted: Fri Nov 30, 2007 12:01 am
by calguy1000
As has been stated numerous times in this forum before (you would have found it with a quick search)..... javascript, because of it's { and } characters conflict with smarty.

You need to use the {literal} and {/literal} tags appropriately so that that doesn't happen.

The exact solution I'll leave as an exercise to you.

[SOLVED] Re: javascript in form gives smarty error

Posted: Fri Nov 30, 2007 12:11 am
by gajones76
thanks Calguy. I'm relatively new to cmsms so please excuse my lack of diligence in looking for the answer.

anyway, i put the {literal} tag around the form code and it works great....

Re: javascript in form gives smarty error

Posted: Fri Nov 30, 2007 12:15 am
by calguy1000
give a man a fish and he eats for a day.....

Re: javascript in form gives smarty error

Posted: Fri Nov 30, 2007 12:39 am
by davendar
Sorry, I can't resist and it is off topic, sort of....the above reply reminds me of a saying I heard once, not sure who coined the phrase....

give a man a program, frustrate him for a day....teach a man to program, frustrate him for a lifetime. :0)

No truer words....and for CMSMS, the more I use this program, the more I love it.

Darling

Re: javascript in form gives smarty error

Posted: Fri Nov 30, 2007 1:28 am
by calguy1000
yeah, that saying is true.... I'm going on 15 years now of 'frustration'