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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

is the function autosubmit the php processing function? If so you have that in javascript script tags. You need to encase it with <?php  ?> tag and take it out of the javascript tags. Can you post a link to your site which this is happening?

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.