I'm displaying data via php from a mysql db. I want to display the data, and add a button called Volunteer at the end. When the user clicks the button, data will be passed to a javascript function that will display a dialog window with yet more data in it.

Here is how I am displaying the data:

        echo "</td><td>";
	echo $row['location'];
	echo "</td><td>";
	echo ?> <input type="button" value="Volunteer"onclick="testing(<?php echo $newdate ?>)" />
......

I need to pass the date to the function testing - problem is I keep getting the error:

missing ) after argument list testing (Sep 05).

How can I pass this argument (which might have spaces in it) to a javascript function?

    You probably need to quote the JavaScript argument:

    onclick="testing('<?php echo $newdate; ?>')"
    

      Also, get rid of that last echo right before the closing ?> tag at the beginning of that line.

        worked like a charm - thanks. don't know how i missed that!

          Write a Reply...