PDA

View Full Version : Popup windows and javascript


sc7389x
03-31-2005, 02:10 AM
Ok, I'm just starting out with javascript and I need some help.
When I click a link, it opens up a new window. However, in the taskbar where you see "javascript: view('1') when I click on the first link, I want the number between the parenthesis to appear on the page in the new window. However, if I click the second link which makes a '2' appear in the part with "view()" I want the popped up window to display the 2.

I program PHP and here's what I have so far (mixed in with php.. but I'm using javascript to get the job done in this case.)


echo "<td>";
//subject
echo "
<SCRIPT language=\"JavaScript\">
function view()
{
mywindow = window.open
(\"pm.php?action=view&messageid=the_number_selected_should_go_here_as_well_as_on_the_page\",\"".$row['subject']."\",\"location=1,status=1,scrollbars=0,width=200,height=200\");
mywindow.moveTo(384,200);
}
</script>";
echo "<a href=\"javascript: view('".$row['id']."')\">".$row['subject']."</a>";
echo "</td>";


$row['id'] is the number between the parenthesis (circled in blue. for example: view('1'))
$row['subject'] is the title of the PM (also circled in blue in the attachment)

Any help would be really appreciated. I've been googling this for like 4hrs. I don't even know what to search for. =/
Thanks in advance.

chasBoy
03-31-2005, 07:14 AM
I am also new to javascript but you can give time to read my solution...
Declare one global var before the function declaration..
and increment it on each function call....
Pass it to the function which displays the number in the status bar
Let me know if this works.....

glenngv
03-31-2005, 11:34 AM
function view(id)
{
mywindow = window.open
(\"pm.php?action=view&messageid=\" + id, \".$row['subject']."\", \"location=1,status=1,scrollbars=0,width=200,height=200\");
mywindow.moveTo(384,200);
}

I'm quite confused if I got the escaped quotes in the correct places. Just remember that the output should be like this:

mywindow = window.open("pm.php?action=view&messageid=" + id, "subject", "location=1,status=1,scrollbars=0,width=200,height=200");

And also take note that the subject, which is used as the window target, should have no space and other special characters (except underscore).

sc7389x
03-31-2005, 02:59 PM
Omg. That was so simple. I tried mywindow = window.open("pm.php?action=view&messageid= + id +", "subject", before but now I see that I put it in the wrong place.
Thanks so much. :thumbsup: