sending php array variable as link to argument of javascript function

I have got a javascript function popitup() which will be used for opening a pop up window. I have PHP Array variable $row_rstest[‘id’] which holds the ID of a data set fetched from database.
I have a page named print_data.php. To view the data of this page the url should be like print.data?id=12
I have taken this in variable $url.

 <?php $url = "print_data.php?id=".$row_rstest['id']; ?>

Then passed this $url in function popitup(). The important thing is to put the sign (‘) around $url variable. Otherwise the function didn’t work for link.

  <?php echo "<a href=\"\" onClick=\"return popitup('$url') \">Click here to open a pop up window</a>"; ?>
          

4 thoughts on “sending php array variable as link to argument of javascript function

  1. how is thta popitup function beacuase in window.opn you need to open a link like form $ url.
    window.open(“URL”)

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s