jtorral
09-09-2011, 09:12 PM
This is all php except for the java code I am struggling with. Please advise.
I have tried this 2 ways and have spent hours on something that should be simple.
I have a string that I am trying to display in an alert box with an onclick
method 1:
$mystring = "<a href=\"mysite.com\">Click</a>";
this does not work
echo "<input type='button' value='Grab Code' onClick=alert('$mystring')>";
nor does this
echo "<input type='button' value='Grab Code' onClick=alert('".$mystring."')>";
nor does anything I try. All I want to do is display the value of mystring in an alert box.
However, this does work ..
echo "<script type='text/javascript'> alert('".$mystring."');</script>";
But I cannot call this from an onclick.
Any help is appreciated.
Thanks
JT
I have tried this 2 ways and have spent hours on something that should be simple.
I have a string that I am trying to display in an alert box with an onclick
method 1:
$mystring = "<a href=\"mysite.com\">Click</a>";
this does not work
echo "<input type='button' value='Grab Code' onClick=alert('$mystring')>";
nor does this
echo "<input type='button' value='Grab Code' onClick=alert('".$mystring."')>";
nor does anything I try. All I want to do is display the value of mystring in an alert box.
However, this does work ..
echo "<script type='text/javascript'> alert('".$mystring."');</script>";
But I cannot call this from an onclick.
Any help is appreciated.
Thanks
JT