I have page1.php that has the a link to a popup. I need to send a variable to the popup window.

I'm currently using this in the body:

<a href="#" onclick="actpopup(<?echo($act_id);?>)"><?echo($date);?></a>

This is the function actpopup

url = "serv_act.php?act_id=act_id";
options = "height=175, width=300, location=no, scrollbars=no,menubars=no,toolbars=no,resizable=yes,left=50";
window.open(url,name,options);

But for line "URL = "serv_act.php?act_id=act_id";, the last act_id i need to be the variable that is in the original link.

Thanks.

Recommended Answers

All 5 Replies

Member Avatar for rajarajan2017
<a href="#" onclick="actpopup(<?php echo $act_id;?>)"><?php echo $date;?></a>
url = "serv_act.php?act_id=act_id";
alert(url); //check whether you get the url properly
options = "height=175, width=300, location=no, scrollbars=no,menubars=no,toolbars=no,resizable=yes,left=50";
window.open(url,name,options);

its not getting the value of the variable act_id, just keeps showing me 'act_id'

thanks i figured it out. you alert(url) helped me alot.

onclick="actpopup('serv_act.php?act_id=<?php echo($act_id);?>')">

Instead of trying to add the php appended to the url, i added it all in the JS variable, and it works.

Thanks again

Member Avatar for rajarajan2017

Yeah, Always the php variable not utilized directly by javascript, you have to use there again <?php with the variable ?>

yeah you to use it again while using javascripts with it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.