Jump to content

help me close a popup


Lodius2000

Recommended Posts

in php i have a form, when you submit the form php runs a function called process form, that does the necesary queries and such and now i need to close the window (since it is a popup aside from the main cms window and has done its purpose)

 

so heres what im coming up with process forms does the queries, then a new form is made that auto submits and closes the window, like so

 

<?php
process_form(){
//do queries

//ok heres what i have
print '
<html>
<head>
<script language="javascript">
function autoSubmit()
{
document.form.submit();
}
</script>
</head>
<body>
<form name="close" method="POST" action="'.htmlentities($_SERVER['PHP_SELF']).'?id=' . $id . '">
<input type="hidden" name="_submit_check1" value="1" />
<input type=button value="Close This Window" onClick="javascript:window.close();">
<script language="JavaScript">
if (`_submit_check1`)
{
autoSubmit();
}
</script>
</body>
</html>';
}
?>

 

so this makes a button called Close This Window as i would expect it to do but it doesnt auto submit (that i can tell) because clicking the button does close the window

 

also, I know pretty much zero javascript, so this it patched together from the internet and to me, it doenst look like it should work, which indeed it doesnt, but i dont know what i have to do to fix it, so help please

Link to comment
https://forums.phpfreaks.com/topic/130021-help-me-close-a-popup/
Share on other sites

Well I see a couple errors with this. Put the <script> tags in the head section. Another one is to not have <script language="javascript">. That is the depreciated way of doing it. Use <script type="text/javascript">. Try that stuff then tell me how it goes. Also no one really uses print anymore. Try echo but I don't think that would really help the output.

ok now its

 

<html>
<head>
<script type="text/javascript">
function autoSubmit()
{
document.form.submit();
}
</script>
</head>
<body>
<form name="close" method="POST" action="'.htmlentities($_SERVER['PHP_SELF']).'?id=' . $id . '">
<input type="hidden" name="_submit_check1" value="1" />
<input type=button value="Close This Window" onClick="javascript:window.close();">
<script type="text/javascript">
if (`_submit_check1`)
{
autoSubmit();
}
</script>
</body>
</html>

 

and im getting the same results

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.