Forum Moderators: open
The window.open is within a JavaScript function
as is the variable reference.
I can perform an "Alert" and can see the value of the
variable (and it is there and correct) before the code
for the window.open.
Is there a way to pass the value of the JavaScript variable to the query_string of the URL?
My CODE:
print("<script language='JavaScript'>"); TYPE='text/javascript'
print("<!--
function popup(ref_param)
{
var rec_param=ref_param;
alert(rec_param);
window.open('http://www.j-nasa.net/cgi-bin/fullrec.pl?code=rec_param', 'FullRecord',' width=1000,height=650,scrollbars=yes');
}
print //-->");
print("</SCRIPT>");
and the call to this function:
print("<TD WIDTH=95><A HREF='JavaScript:onClick=popup($ecn_ref ) '>$ecn_ref</A></TD> ");
The Perl variable passes just fine and is converted into a JavaScript variable with no errors
BUT the JavaScript variable will not work in the query_string portion of the window.open call.
I can put a Perl variable in query_string portion and it will work fine - which is odd seeing that the URL is part of a JavaScript function and I produce no errors doing this.
<script type="text/javascript">
function popup(ref_param){
var myString = 'http:\/\/www.j-nasa.net/cgi-bin/fullrec.pl?code=' + ref_param;
alert(myString);
window.open(myString, 'FullRecord', 'width=1000,height=650,scrollbars=yes');
}
</script>
<a href="#" onclick="javascript:popup('$ecn_ref')">$ecn_ref</a>
The most significant error in your code was that you made "rec_param" a hard coded part of the URL of the window you opened.
Looks like RonPK beat me to it :)