Solved

Refresh having a Form with Post

Posted on 1998-08-19
9
220 Views
Last Modified: 2010-04-09
Hi
I have a html-doc that I want to refresh every n seconds.
I know how to do that whit the
<meta hhtp-equiv="refresh" content="n">
but my problems is that I use a Form with method=post
and then the reader(IE4 or netscape) ask the user
if he want to repost data.
How do I do so the reader doesn't come up with
that window every time.
/Pelle
0
Comment
Question by:PerBoman
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 10

Expert Comment

by:MasseyM
ID: 1836838
Rather than POST use the GET method... You will have the ugly URL string, but the info will not have to be "reposted"
0
 

Author Comment

by:PerBoman
ID: 1836839
I don't want to use GET becuse I have Made a cgi program
on the server that retrive info by the POST command.

 
0
 
LVL 10

Expert Comment

by:MasseyM
ID: 1836840
Why don't you write the program to parse the query string and do it that way?  Otherwise, you will always get that message...

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:Trevor013097
ID: 1836841
PerBoman,

Matt is right.  You should write your CGI so that it parses whatever you send it and therefore can handle both POSt and GET methods. There are plenty of scripts which are available which will do just that (just look at some of the scripts on Matt's Script Archive under PERL).  The lines needed to do this aren't all the long (about 10 if my memory serves me right).

Your other option if you have to use POST would be to have a Javascript handle the form submission.  Your form would then called a Javascript function onSubmit.  The function would then after a timeout submit your form.  This would then be a resubmission rather than a refresh (ultimately with the same effect) and so IE and NN wouldn't give you the prompt message.

Hope that helps a little.

Trevor.


0
 
LVL 2

Expert Comment

by:bernfarr
ID: 1836842
Don't forget the data limitation on GET methods. If you have large amounts of data coming in on the form, you must use POST.
0
 
LVL 5

Expert Comment

by:Trevor013097
ID: 1836843
That is very true, which is much of the reason we all started using POST, so maybe the POST method is the better to stick with.  Which means that the Javascript might be the way to go then.

Trevor.


0
 
LVL 5

Accepted Solution

by:
Trevor013097 earned 50 total points
ID: 1836844
PerBoman,

I have written a small script which can resubmit your form without giving the prompt. You can change the amount of time between submits by changing the value (in milliseconds) in the setTimeout line. Here is the script:

<HTML>
<HEAD>
<TITLE>Resubmitting Javascript Form</TITLE>
<SCRIPT LANGUAGE="Javascript">
<!--

function formSubmit() {
  if (document.myForm.stopForm.checked != true) {
      document.myForm.submit();
      setTimeout("formSubmit();", 1000);  // form submits after 1 second (1000 milliseconds)
  }
}

//-->
</SCRIPT>
</HEAD>

<BODY BGCOLOR="#FFFFFF">

<FORM NAME="myForm" METHOD="POST" ACTION="http://www.someserver.com/somescript.pl">
<B>myField1</B> <INPUT TYPE="TEXT" NAME="myField1" SIZE="20"><BR>
<B>myField2</B> <INPUT TYPE="TEXT" NAME="myField2" SIZE="20"><BR>
<B>myField3</B> <INPUT TYPE="TEXT" NAME="myField3" SIZE="20"> <INPUT TYPE="checkbox" NAME="stopForm"> Check box to stop form submitting after this time<BR>
     <INPUT TYPE="BUTTON" NAME="SubmitButton" VALUE="Send the Form" onClick="formSubmit();">
<INPUT TYPE="RESET" NAME="ResetButton" VALUE="Clear the Form">
</FORM>

</BODY>
</HTML>

If you have a problems please let me know.

Trevor.


0
 

Author Comment

by:PerBoman
ID: 1836845
Thank you for telling me about the method form.submit()

0
 
LVL 5

Expert Comment

by:Trevor013097
ID: 1836846
Glad to be of help.

Trevor.


0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to refresh a page from a sub domain in ajax ? 34 43
Media Queries  not Firing 6 26
output of netstat -r in Powersshell HTML 3 45
links not working 2 25
Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question