...

View Full Version : PHP and my javascript requires ' Apostrophes



bradwbowman
11-19-2006, 08:37 AM
My php code looks like this

echo userform ('', '<input readonly type="text" name="listing_description_counter" size="5" maxlength="5" value="' . $conf['listing_description_size'] . '"> ' . $lang['Characters_Left'] . ' test ') ;

Where the test is, I need to put in the following Javascript coding and since this coding has Apostrophes, it is giving me an error when it is run on my apache server. Disphelp is a function.

<a href="javascript:openJavaScriptFunction();" id="none" onmouseover="Disphelp(this,'moon',false)" onmouseout="Disphelp(this,'moon',true)">display on page</a>


I figured I could reference an outside .js file, but then I would have to make about 20 different .js files and that would not be very efficient.

Any Ideas?

Thanks,
Brad

SeeIT Solutions
11-19-2006, 12:14 PM
just escape any single quotes.


echo userform ('', '<input readonly type="text" name="listing_description_counter" size="5" maxlength="5" value="' . $conf['listing_description_size'] . '"> ' . $lang['Characters_Left'] . ' <a href="javascriptpenJavaScriptFunction();" id="none" onmouseover="Disphelp(this,\'moon\',false)" onmouseout="Disphelp(this,\'moon\',true)">display on page</a> ') ;

bradwbowman
11-19-2006, 08:04 PM
Excellent,

Adding the \before the ' and everything worked great.

Thanks,
Brad



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum