user1605871
user1605871

Reputation: 735

Echo Javascript Variable in Php to another page

I have code which passes php variable to another page on my site:

echo'<a class="btn btn-danger" style="margin-left:10px;width:120px;float:left;"  href="fullsizemarket.php?imageid=',$imageid,'&action=removed">Remove from Cart</a>';

I am able to retrieve the php variable $imageid by the following:

$imageid = htmlentities($_GET['imageid']);

I want to also pass in this code the value of a javascript variable. The variable is set in an earlier part of the code as follows:

     var rowcount

I don't know how to pass var rowcount in the same echo code as I pass $imageid. What is the code to do this?

Upvotes: 0

Views: 432

Answers (1)

Fedor  Avetisov
Fedor Avetisov

Reputation: 26

How bout following:

echo 
"<a class='btn btn-danger' 
    style='margin-left:10px;width:120px;float:left;' 
    href='fullsizemarket.php?imageid=$imageid&action=removed&rowcount='
    onclick = \" this.setAttribute('href', this.getAttribute('href')+rowcount) \"
 >Remove from Cart</a>";

Upvotes: 1

Related Questions