Jump to content

php, open new window with javascript


cjkeane

Recommended Posts

Hi everyone.

 

i need to open a new window in php using a bit of javascript.. or maybe not, with an id number. any help would be appreciated. This code doesn't do anything even though there are no errors. Any ideas on how why?

 

<input type="submit" name="SaveData" id="SaveData" value="Save" />

<?php
if (isset($_POST['SaveData']))
{ 

$loc = "saveddata.php?IDNumber=" . $IDNumber;
	echo "<script LANGUAGE='JavaScript'>";
	echo "window.open($loc,'mywin','left=20,top=20,width=500,height=500,toolbar=0,resizable=1')";
	echo "</script>";
}
?>

 

Link to comment
https://forums.phpfreaks.com/topic/231513-php-open-new-window-with-javascript/
Share on other sites

Thanks. i'm sure that would work, but i wanted them to click on a button to open the page in a new window, not on a text link. can the below be modified to use the submit button named 'Save'? thx.

 

 

<a href="<?php echo "receive.php?IDNumber=" . $IDNumber; ?>" target="_blank">TitleM</a>

<button onclick="javascript: window.open('SavaData.php?IDNumber=<?php echo $IDNumber; ?>','mywin','left=20,top=20,width=500,height=500,toolbar=0,resizable=1')">Click!</button>

 

Next time, you might try something yourself because this is not really helping you learn whatsoever.

I have been trying many different methods before posting on here. i tried everything from a meta refresh, to using a header location, to using javascript to open a new window. i even tried to combine javascrpt and php with little luck. i am able to open the page in the same window with the idnumber, but i need to have the window popup and control how the window looks. i'm getting closer, but i need something to work similar to this:

 

<?php

// if Save button clicked, insert data into table
if (isset($_POST['Save']))
{ 
    mysql_query("INSERT INTO data(IDNumber, FirstName, LastName) 
    VALUES ('$IDNumber', $FirstName, $LastName") or die(mysql_error()); 
    echo "<script>";
    echo "window.open('SavedData.php?IDNumber=<?php echo $IDNumber; ?>', width=330,height=330,left=100, top=25)";
    echo "</script>";
}
?>

 

nothing happens though. the window needs to open automatically to display the saved data.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.