lets say i wanna go with echo, how do i need to quote or escape the current code, that it works? cause i have no idea how to implement the value thing..
thanks..appreciate it On 30 Okt., 05:52, Ryan Schmidt <[email protected]> wrote: > On Oct 29, 2011, at 10:56, Tomfox Wiranata wrote: > > > echo '<div id="showGoogleMap" onclick="showGoogleMap('.$all['id'].','. > > $all['BooksUser']['latitude'].', > > '.$all['BooksUser']['longitude'].','.$all['title'].')" > > style="float:right;cursor:pointer;">'.$html->image("icons/map.png", > > array("alt" => "Google Map anzeigen")).'</div>'; > > [snip] > > > now when I hit > > the icon to open the map, firebug says this: > > ------------------------------------------------------------------------------------------------------------------------------------------------------------- > > > missing ) after argument list > > showGoogleMap(207,47.378824,8.548737,Tag Heuer Carrera Chronograph) > > As you see from the error message (or by viewing source on the page), your > PHP code generated the following HTML code: > > <div id="showGoogleMap onclick="showGoogleMap(207,47.378824,8.548737,Tag > Heuer Carrera Chronograph)" style="float:right;cursor:pointer;">...</div> > > What got generated inside the onclick attribute is not valid JavaScript code, > because the title string is not quoted or escaped properly. You probably want > to use JsHelper::value($all['title']) instead of just echoing $all['title'] > directly. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
