Problem combining PHP with JavaScript What I am trying to do is to add php-function-generated argument to JavaScript function. The point of the function is to give user a possibility to add dropdown boxes to the form (for additional values). echo '<a href="javascript:;" onClick="function(\''.function().'\')">'; PHP: Function() returns a list of <option value="int">string</option>. The problem is, that I run out of possible quotes (meaning, the first double quotes of option value will end the ones of onClick. I have also slashed out one set of single quotes in JavaScript function, so I can’t use them either.
Yes, sorry, that was mistake I made when writing the example line to that post. I my real code the slashes weren't reverses. Thank you for pointing that out, I'll fix it in the first post.
Just a suggestion. Forget that and use the <?php ?>. That is the way I use all the time, and, by the way, the coding style everybody use (at least the coders behind Wordpress, Joonla, Drupal and so ) So the call will be something like this <a href="javascript: onClick="<?php echo "function('function()')"; ?>;"> Code (markup):