Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mixing php and javascript

Status
Not open for further replies.

wolf73

Programmer
Joined
Feb 12, 2006
Messages
93
Location
CA
the following code works

<?
$attrib = Array();
$attrib["onclick"] = "javascript:window.location='add'";

?>

the following gives me error, here $s is a php variable, it gives me junk value (disable?id=Object%20id%20#7%3E)


<?
$attrib = Array();

$attrib["href"] = "javascript:if(window.confirm('Are you sure you want to disable this site?')){window.location='disable?id=$s>'}";

?>

how can i fix that?

Thanks
 
gives me [an] error" is pretty vague. And I cannot reproduce the error with the code you have provided.



Want the best answers? Ask the best questions! TANSTAAFL!
 
It looks faintly to me that the problem is in this part of the statement:

{window.location='disable?id=$s>'}";


is $s a variable that is supposed to be dereferenced and contatenated into the string, or is it supposed to be a string literal?







Want the best answers? Ask the best questions! TANSTAAFL!
 
Thanks, I nwas able to fix it , following code works

<?
$attrib = Array();

$attrib["href"] = "javascript:if(window.confirm('Are you sure you want to disable this site?')){window.location='disable?id=".$s->id."'}";

?>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top