homepage Welcome to WebmasterWorld Guest from 54.227.41.242
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Problem with PHP and JS
andrewsmd




msg:4099885
 9:02 pm on Mar 17, 2010 (gmt 0)

I am trying to run a javascript function with PHP. However, I get a JS error saying unterminated string literal with this php code. Echo("<a href = # onclick=checkName('{$rcd}', '{$title}')> Del </a>");
The only problem I can see is that in the html it looks like this checkName('91', 'AD1 Moore'); The script stops at the blank white space. Any ideas why a white space is causing me issues? I should note that checkName calls some AJAX stuff.

 

gsmith




msg:4099971
 11:30 pm on Mar 17, 2010 (gmt 0)

Why is there a hash mark after href = ?

Also, if this is supposed to by XHTML, then the attribute value has to be enclosed in double quotes.

rocknbil




msg:4100002
 11:55 pm on Mar 17, 2010 (gmt 0)

Right, needs quotes.

echo "<a href=\"#\" onclick=\"checkName('$rcd', '$title')\"> Del </a>";

Readie




msg:4100005
 12:03 am on Mar 18, 2010 (gmt 0)

Just a note, I seem to recall reading echo is not treated like a function and so will not work with brackets when more than one parameter is passed to it. Whether that means concatonated variables, or variables split with a delimiter of some sorts I don't know.

andrewsmd




msg:4100014
 12:16 am on Mar 18, 2010 (gmt 0)

That's what I was missing. The \ was just a typo. Thanks guys, it's been a while since I've done anything with PHP. I guess I got too used to .net and it handling all of that "AJAX stuff" for me! I've used echo with multiple variables a lot before. Could this be a version issue? I've never had a problem with it.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved