What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » html form/javascript help

html form/javascript help
Author: Message:
MeEtc
Patchou's look-alike
*****

Avatar
In the Shadow Gallery once again

Posts: 2200
Reputation: 60
38 / Male / Flag
Joined: Nov 2004
Status: Away
O.P. html form/javascript help
I'm trying  to make a form submit to a new popup window opened with javascript, close after loading, and have the form page simply refresh.

Here's what I have so far:
code:
<form action='script.php' method='post' target='WindowName'
    onSubmit="func=window.open('', 'WindowName', 'height=100,width=100');
    setTimeout(window.location.reload(true), 2000)">
<!-- Form elements -->
<input type='submit' value='Submit'>
</form>

The window will open and the script will open there. But, the form will not refresh and I don't know how to close the new window after it loads. I need all of the JS to be inline, not have an external script.

can anyone help?

This post was edited on 10-24-2006 at 05:32 PM by MeEtc.
[Image: signature/]     [Image: sharing.png]
I cannot hear you. There is a banana in my ear.
10-24-2006 03:17 PM
Profile PM Web Find Quote Report
rav0
Veteran Member
*****

Avatar
i have an avatar

Posts: 1419
Reputation: 29
34 / Male / Flag
Joined: Aug 2003
RE: html form/javascript help
Couldn't you just get rid of the popup and have the page submit to itself?

To close the popup, in the popup page, window.close.

I don't know why the refresh doesn't work, but maybe it's because of no semicolon. You could also try document.location=document.location. Why do you need the timer?
| [Image: dorsh] |

(\ /)
(O.o)
(> <)

This is Bunny. Copy Bunny into your signature to help him on his way to world domination
10-25-2006 07:36 AM
Profile E-Mail PM Web Find Quote Report
hmaster
Senior Member
****

Avatar

Posts: 716
Reputation: 24
33 / Male / Flag
Joined: Nov 2004
RE: html form/javascript help
Make script.php with the script you want to execute when they press submit and add at the end window.close.

Your form should work like this:
code:
<form action='' method='post' onSubmit="window.open('script.php', 'WindowName', 'height=100,width=100'); setTimeout(window.location = unescape(window.location.pathname), 2000);return false;">
<!-- Form elements -->
<input type='submit' value='Submit'>
</form>
I think thats what you're trying to do?
[Image: sig.png]
10-25-2006 10:09 AM
Profile PM Web Find Quote Report
MeEtc
Patchou's look-alike
*****

Avatar
In the Shadow Gallery once again

Posts: 2200
Reputation: 60
38 / Male / Flag
Joined: Nov 2004
Status: Away
O.P. RE: html form/javascript help
quote:
Originally posted by rav0
Couldn't you just get rid of the popup and have the page submit to itself?
No, I don't have access to the script itself
quote:
Originally posted by rav0
Why do you need the timer?
to wait for the script to execute before refreshing, as it impacts the form page.
quote:
Originally posted by hmaster
Make script.php with the script you want to execute when they press submit and add at the end window.close.
I tried winFunc=window.open... and winFunc.document.onload=winFunc.close() combinaton, but get a security warning when trying to do it.

quote:
Originally posted by hmaster
Your form should work like this:
code:
<form action='' method='post' onSubmit="window.open('script.php', 'WindowName', 'height=100,width=100'); setTimeout(window.location = unescape(window.location.pathname), 2000);return false;">
<!-- Form elements -->
<input type='submit' value='Submit'>
</form>
I think thats what you're trying to do?
Will that actually submit the form info to script.php though?
[Image: signature/]     [Image: sharing.png]
I cannot hear you. There is a banana in my ear.
10-25-2006 12:14 PM
Profile PM Web Find Quote Report
hmaster
Senior Member
****

Avatar

Posts: 716
Reputation: 24
33 / Male / Flag
Joined: Nov 2004
RE: html form/javascript help
Oh right you wanted to carry it over to the popup which is easily done through GET methods.
code:
<form action='' method="post" onSubmit="window.open('script.php?submit=' + this.elements['submit'].value + '&name=' + this.elements['name'].value, 'WindowName', 'height=100,width=100'); setTimeout(window.location, 2000); return false;">
    <input type="text" name="name" /> <!-- just testing -->
    <input type="submit" name="submit" value="Submit" />
</form>
And I tested this in a file called script.php:
code:
<?php
$tf = (isset($_GET['submit'])) ? "True" : "False";
$name = (isset($_GET['name'])) ? $_GET['name'] : "False";

echo $tf;
echo "<br />";
echo $name;
?>
Which outputted:

    True
    Boo (this being what I put in the name input).
Only downside is that you have to put all of the names of the input boxes that you want to send over to script.php in the window.open() function.

This post was edited on 10-26-2006 at 10:26 AM by hmaster.
[Image: sig.png]
10-25-2006 07:40 PM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On