PHP Values in JS function
Posted: Mon Apr 12, 2004 11:29 pm
Simple window open script:
That I call later like
Works well, but the page it opens has the following URL:
http://localhost/public/addcomment.php? ... rticle=num
Which isn't what I want. I need it to have the &article equal the value given to it by the $_GET['doc']. I tried combining PHP and Javascript in the original function, but it didn't work. Is there a way of allowing Javascript to get the GET variables? Better yet, how can I make this method work?

Code: Select all
function addComment(num){
window.open('addcomment.php?ref=articles_comments&article=num','Add A Comment', 'width=500,height=360,resizeable=no');
}Code: Select all
<a href="javascript:addComment(<?php echo $_GET['doc']; ?>);">Add A Comment</a>http://localhost/public/addcomment.php? ... rticle=num
Which isn't what I want. I need it to have the &article equal the value given to it by the $_GET['doc']. I tried combining PHP and Javascript in the original function, but it didn't work. Is there a way of allowing Javascript to get the GET variables? Better yet, how can I make this method work?