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
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>

Link to comment
Share on other sites

yes, but i still need to open the window using the variable eh saveddata.php?IDNumber

 

Something like this ?

<button onclick="javascript: window.open('receive.php','mywin','left=20,top=20,width=500,height=500,toolbar=0,resizable=1')"></button>

Link to comment
Share on other sites

<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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.