Jump to content

[SOLVED] Passing JS variable in PHP


millercj

Recommended Posts

Hi everyone, i'm having an issue with executing a js command through php. The only problem as of now is that i'm trying to pass a variable which is a variable in my php script so I've done this:

 

echo "<p>". $classes[$i][0]." - ".$classes[$i][1]." <a href='#' onclick='deleteclass(".$classes[$i][0].")'>delete</a></p>";

 

The variable gets correctly passed into the deleteclass() funtion but I still need quote around the variable for it to work.

 

What is the correct syntax to make this work correctly?

Link to comment
https://forums.phpfreaks.com/topic/135914-solved-passing-js-variable-in-php/
Share on other sites

ok, what is currently happening is when the script is echoed back it ends up looking like this:

 

<p><a href="#" onclick="deleteclass(4A)">delete</a></p>

 

and I need to get quotes around the 4A so it'll execute...but I have all these quote in my php script but can't seem to get the right syntax

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.