473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Refresh or close after form submission

219 100+
I have a page that I want to be refreshed after a user submits a form. I also have another page that I want to be closed after a user submits a form.

How would I go about doing this??
Nov 7 '08 #1
21 17015
gits
5,390 Expert Mod 4TB
could you explain that a bit more? what do you mean with closing a page - do you mean closing a window that displays a page? when you submit what happens then - do you call a php script that you control?

kind regards
Nov 7 '08 #2
dmorand
219 100+
I have a popup form that's used to submit comments. When the user clicks the submit button, I'd like the popup window to close once the submission takes place.
Nov 10 '08 #3
gits
5,390 Expert Mod 4TB
just call a js-function onsubmit of your form that uses window.close()

kind regards
Nov 10 '08 #4
dmorand
219 100+
just call a js-function onsubmit of your form that uses window.close()

kind regards
Excellent, I'll give that a try
Nov 10 '08 #5
dmorand
219 100+
How come if I try to do this:

onSubmit="window.location.reload();" in my form tag it's not submitting the form, it's just refreshing the screen. I want the screen to refresh after the form gets submitted to allow the user to enter a new form without having to jump between screens.
Nov 12 '08 #6
acoder
16,027 Expert Mod 8TB
onsubmit is called as soon as the submit button is pressed, not after the submit takes place. Add the refresh to the submitted page instead.
Nov 13 '08 #7
I have the same problem as I want to make the submit button refresh.

I have 3 frames on my page and need the page to refresh after a submit button is pressed for its changes to take effect (change style sheet)

However using


<input type="submit" onSubmit="window.location.reload();" value="Go">just submits and does not refresh.

I am using the http://php.about.com/od/finishedphp1...s_switcher.htm script.

Does anyone know how to make the button refresh the page as well?
Jun 10 '09 #8
acoder
16,027 Expert Mod 8TB
onsubmit is a form event, not an input button event. In any case, that wouldn't work either. I assume the form is in a frame and the form submits to the same frame. What you'd need to do is refresh the whole page after the page has been submitted.
Jun 11 '09 #9
Yes, I don't want my visitors to have to manualy do that.

I was thinking of putting js into my cookie.php which is what the form is linked to.
But don't know what to add?
Jun 11 '09 #10
acoder
16,027 Expert Mod 8TB
You'd need to reference the parent using 'parent' or 'top' and then reload. It is possible to change styles without reloading the page. One other thing: if possible, try to avoid frames.
Jun 11 '09 #11
I tried targeting it with _Parent but it just loaded the same frame in the frame that was suppost to refresh.
Jun 11 '09 #12
acoder
16,027 Expert Mod 8TB
Do you only want to reload one frame or the page which contains the 3 frames?
Jun 11 '09 #13
just 1 other frame would do, but either. If its possible to reload the whole page then i'd prefer that.
Jun 11 '09 #14
acoder
16,027 Expert Mod 8TB
To access the parent (the page containing the frames) and reload it:
Expand|Select|Wrap|Line Numbers
  1. parent.location.reload();
You would call this after page load in one of the frames. Is there any particular reason why you're using frames?
Jun 12 '09 #15
Where would I put that thought.

Its part of the design.
Jun 12 '09 #16
acoder
16,027 Expert Mod 8TB
You can put it in the form action page:
Expand|Select|Wrap|Line Numbers
  1. window.onload = function() {
  2.     parent.location.reload();
  3. }
Jun 12 '09 #17
Thank you very much.
Thats the one.. nearly, as this runs the whole page in a loop :P
I just added
Expand|Select|Wrap|Line Numbers
  1. framename.document.
  2.  
So the whole code reads

Expand|Select|Wrap|Line Numbers
  1. window.onload = function() { 
  2.     parent.framename.document.location.reload(); 
  3.  
Once again, thank you very much for your help, I do appreciate it. :)
Jun 13 '09 #18
The only problem I have is that it makes the target frame a bit jumpy when it loads as it has to load twice the first time round (initial load, and refresh).

So is it possible to only run the script when the button is submitted?
I have tried the following but it did not work.
Expand|Select|Wrap|Line Numbers
  1. <input type="submit" value="Go" onSubmit="parent.framename.document.location.reload();">
  2.  
Jun 13 '09 #19
acoder
16,027 Expert Mod 8TB
Use PHP code to decide if the code should exist. Only have the JavaScript code run if the form has been submitted, e.g.
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2.     if (isset(...)) {
  3. ?>
  4. <script type="text/javascript">
  5. ...
  6. </script>
  7. <?php
  8.     }
  9. ?>
Jun 14 '09 #20
It does not refresh when clicked, what have I done wrong?

This is the code in the form frame.

Expand|Select|Wrap|Line Numbers
  1. <?php  
  2.     if (isset($var)) { 
  3. ?> 
  4. <script type="text/javascript"> 
  5. $var window.onload = function() {  
  6.     parent.frameName.document.location.reload();  
  7. }  
  8. </script> 
  9. <?php 
  10.     } 
  11. ?>
  12.  
Jun 21 '09 #21
acoder
16,027 Expert Mod 8TB
No, it doesn't quite work like that. You need to replace $var with the posted variable in PHP, e.g. $_POST['submit']. Also remove $var on line 5. If you have any more problems on that front, ask in the PHP forum.
Jun 21 '09 #22

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Martin the Mac Addict | last post by:
Good evening to the skilled Ladies and Gentlemen of the PHP world. I am fairly new to all of this but learning quickly. I have run in to a need to remove blank lines from a form submission after...
5
by: ratlhead | last post by:
Hey all, I'm attempting to do some form processing on a server that has register_globals off, however, I've run into a confusing situation and need some help. Basically, the form is a...
3
by: Chris Smith | last post by:
Good morning, Is there a good way to use JavaScript to send a form submission, but get back the response as a string, rather than loading it into a page? I could write the code to send the...
17
by: Jim Little | last post by:
Hello, I'm driving myself crazy either because I'm missing something about ASP.NET, or what I'm trying to do simply can't be done. First, I am not using session variables to track state. My...
4
by: kschneider | last post by:
Assume there's a form with it's action attribute all set to post to a URL, but without a submit control. Form submission is done via a link and I want to prevent the classic "double submit"....
6
by: Oleg Konovalov | last post by:
Hi, I have a Java/JavaScript GUI application where I perform a lot of long DB operations , which takes 5-60 secs to perform. Sometimes user double-clicks the button or just gets impatient and...
1
by: Homer | last post by:
Hi, I just got a requirement from my HR department to automate their form submission process and integrate it into the Intranet project that I had just completed Phase 1 of. Because of the...
1
by: rn5arn5a | last post by:
Nowadays, most websites make use of CAPTCHA to prevent automated Form submission. Can someone please give me examples of how automated Form submission can be achieved? It's not that I intend to...
6
by: Stanimir Stamenkov | last post by:
I have a form without a submit button like: <form name="form1" action="" onsubmit="alert('submit ' + this.name);"> <div> <label>Field 1: <input type="text" name="field1"...
0
Thekid
by: Thekid | last post by:
I'm trying to auto send a form submission to a website but it isn't working. I've done this before and it worked but for some reason, using the same basic code, it doesn't seem to submit it. I'm...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.