On Nov 2, 2011, at 15:09, Tomfox Wiranata wrote: > i had to use backslashes...^^ it works now > > thanks for your time guys..appreciate it :)
Yes, well, if you're going to insert data into a page, you need to quote and escape that data appropriately. In this context, you're trying to put a string into JavaScript code. So you need to quote it (' or " around it), and you need to escape any special characters in its content (', ", \, newline, carriage return). That JavaScript is also inside an HTML attribute, so you need to apply HTML escaping rules too. This seems like a fairly common need -- to escape data for insertion into JavaScript code -- so I assumed there would be a method in CakePHP to do that for you. My quick search turned up $this->Js->value(). Actually getting that embedded into an attribute of an HTML element like you're wanting to do, however, seemed to be more difficult. -- 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php