javascript in form gives smarty error

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
gajones76
Forum Members
Forum Members
Posts: 12
Joined: Sun Jul 15, 2007 10:51 am

javascript in form gives smarty error

Post 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
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: javascript in form gives smarty error

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
gajones76
Forum Members
Forum Members
Posts: 12
Joined: Sun Jul 15, 2007 10:51 am

[SOLVED] Re: javascript in form gives smarty error

Post 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....
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: javascript in form gives smarty error

Post by calguy1000 »

give a man a fish and he eats for a day.....
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
davendar
New Member
New Member
Posts: 5
Joined: Sat Sep 23, 2006 11:16 pm

Re: javascript in form gives smarty error

Post 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
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: javascript in form gives smarty error

Post by calguy1000 »

yeah, that saying is true.... I'm going on 15 years now of 'frustration'
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Post Reply

Return to “CMSMS Core”