Page 1 of 1

PHP Values in JS function

Posted: Mon Apr 12, 2004 11:29 pm
by Steveo31
Simple window open script:

Code: Select all

function addComment(num){
window.open('addcomment.php?ref=articles_comments&article=num','Add A Comment', 'width=500,height=360,resizeable=no');
}
That I call later like

Code: Select all

<a href="javascript:addComment(<?php echo $_GET['doc']; ?>);">Add A Comment</a>
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?

:)

Posted: Tue Apr 13, 2004 2:49 am
by feyd

Code: Select all

window.open('addcomment.php?ref=articles_comments&article='+num,'Add A Comment', 'width=500,height=360,resizeable=no');
fix old-new php highlighter

Posted: Tue Apr 13, 2004 4:28 am
by Steveo31
You rock.

:D