Click to See Complete Forum and Search --> : syntax error


tomhilton
11-08-2003, 01:00 PM
hi, I keep getting a javascript syntax error when the page containing this script loads. When I refresh the page, I do not get an error, and I am able to click on the object and the new window opens up. Does anyone see what the syntax error could be, or why it doesn't occur when I refresh, or leave the page and come back to it. The error only happens the first time I load the page.

<a href='#' onClick=javascript:window.open('single_photo.php?info=$id','photo_page','width=420,height=360,direct ories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no,screenX=25,screenY=1 00,top=25,left=100') style='text-decoration: none; color: #00FFFF'>

The anchor tag above is within a php tag that is passing the $id variable, thus the single quotes. Any suggestions, corrections would be greatly appreciated.

demo
11-08-2003, 03:03 PM
hey,

the only thing that i can see wrong is that there is a space:

single_photo.php? info=$id


so delete the space ie:

<a href='#' onClick=javascript:window.open('single_photo.php?info=$id','photo_page','width=420,height=360,direct ories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no,screenX=25,screenY=1 00,top=25,left=100') style='text-decoration: none; color: #00FFFF'>

demo

tomhilton
11-08-2003, 03:41 PM
Demo,

Thanks for your response, I've taken a different tack, creating a function in the header as below:

function meatloaf(page,name,)
{
var openup
openup=window.open(page,name,'width=480,height=360,directories=no,location=no,menubar=no,scrollbars= no,status=no,toolbar=no,resizable=no,screenX=25,screenY=100,top=25,left=100')
}

In the body I call the function as such:

<a href='#' onclick="meatloaf('destination','photopage')">

It works fine when "destination" is an html page with no variable being passed, but I have to pass a variable to the popup page so it will pull a record from a database. I passed this php variable to javascript as follows:

var upload_id = <?php echo "$id" ?>;
var destination="single_photo.php?info="+upload_id;

I know this javascript "destination" variable is correct, because i did a document.write(destination) and it is exactly what it needs to be. Problem is my anchor tag doesnt seem to be picking it up, it appears to be passing a null "destination" value to the function's "page" field, I keep getting "object expected" error. Do I need the anchor tag to be inside the javascript tags where I define "destination"? What is the javascript way to write the anchor tag? (ie; document.write("<a href='#' onclick='meatloaf('destination','photopage')'>")

Sorry this is getting so convoluted, any help is greatly appreciated.

tomhilton
11-08-2003, 03:56 PM
Demo,

Thanks again, I was able to make it work after creating the function in the header.