cjkeane Posted March 23, 2011 Share Posted March 23, 2011 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>"; } ?> Quote Link to comment Share on other sites More sharing options...
MrXHellboy Posted March 23, 2011 Share Posted March 23, 2011 <a href="<?php echo "receive.php?IDNumber=" . $IDNumber; ?>" target="_blank">TitleM</a> Quote Link to comment Share on other sites More sharing options...
cjkeane Posted March 23, 2011 Author Share Posted March 23, 2011 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> Quote Link to comment Share on other sites More sharing options...
MrXHellboy Posted March 23, 2011 Share Posted March 23, 2011 Something like this ? <button onclick="javascript: window.open('receive.php','mywin','left=20,top=20,width=500,height=500,toolbar=0,resizable=1')"></button> Quote Link to comment Share on other sites More sharing options...
cjkeane Posted March 23, 2011 Author Share Posted March 23, 2011 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> Quote Link to comment Share on other sites More sharing options...
MrXHellboy Posted March 23, 2011 Share Posted March 23, 2011 <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. Quote Link to comment Share on other sites More sharing options...
cjkeane Posted March 23, 2011 Author Share Posted March 23, 2011 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. Quote Link to comment Share on other sites More sharing options...
cjkeane Posted March 24, 2011 Author Share Posted March 24, 2011 thanks for your help. i figured it out! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.