Refresh the Page

L

laura

I'm doing a page which gathers some text in the form of a text box in a
<form>. This text is saved to a text file, notices.txt and I want to be able
to display the saved text on the page, as soon as they click the SUBMIT
button - is this possible?

At the moment I have a hyperlink called "back" which, once they have entered
the text and they click SUBMIT, the "back" hyperlink will refresh the page
and it displays the newly entered text. However, I want to avoid them having
to press two things in order to see the text they have entered.. i.e., can
the submit button also totally refresh the page and display the newly
entered text?

Thanks
Laura TD
 
M

McKirahan

laura said:
I'm doing a page which gathers some text in the form of a text box in a
<form>. This text is saved to a text file, notices.txt and I want to be able
to display the saved text on the page, as soon as they click the SUBMIT
button - is this possible?

At the moment I have a hyperlink called "back" which, once they have entered
the text and they click SUBMIT, the "back" hyperlink will refresh the page
and it displays the newly entered text. However, I want to avoid them having
to press two things in order to see the text they have entered.. i.e., can
the submit button also totally refresh the page and display the newly
entered text?

Thanks
Laura TD

"... can the submit button also totally refresh the page and display the
newly entered text? -- Yes

However, I have a few questions ...


Where does notices.txt reside -- on the client or on the server?

If on the client you'll have security issues.

If on the server, it will be replaced by every form-filling visitor.


Is the text file formatted so you can display it as-is, or do
you want to read it first so you can format the display?


You could offer a link to the text file which, when clicked,
will open it up in a (optionally new) browser windows.

For example,
<a href="notices.txt">notices.txt</a>
or
<a href="notices.txt" target="_blank">notices.txt</a>
presuming it is on the server in the same folder as your page.
 
L

laura

Thanks for your swift reply.

After I sent the post, I realised I had not been too clear.. my apologies.

notices.txt will be on the server. It's going to be on an intranet. Only one
paragraph of text will be saved at any one time and the idea is that only
one person will ever actually edit this text, via a password protected area
of the website and possibly on a daily basis and the results will be
displayed on the home page of the intranet as "Daily Notices".

The person entering the text will see the previous day's Notice at the top
of the screen, and I am doing this with <!--#INCLUDE FILE="notices.txt"-->,
which works fine the first time they open the page. Underneath the "old"
notice will be a <FORM> with one text box for them to fill in, and a SUBMIT
button to submit the new text. When they click the SUBMIT button, the text
gets saved immediately to notices.txt.

It is at this point that I want the newly saved text to be displayed once
again at the top of the (refreshed) page, with a black <FORM> underneath,
giving them the opportunity to read what they wrote and possibly change it
if they wish.

I seem to be able to achieve this only if I have a "back" button (<a
href="notices.asp">Back</a> which just totally reloads the page and then
seems to read in the newly entered text. The form says <FORM
action="notices.asp" method="post">.

I'm not sure why the SUBMIT button does not do the same "job" as the back
button and totally refresh the page with the newly entered and saved text.
I'm confused.

I hope this explains it a bit better.
Is the text file formatted so you can display it as-is, or do
you want to read it first so you can format the display?

Formatting is not a problem, I just want to display the most currently
entered text.

This text will then also be displayed on the home page of the intranet.

Laura
 
M

McKirahan

laura said:
Thanks for your swift reply.

After I sent the post, I realised I had not been too clear.. my apologies.

notices.txt will be on the server. It's going to be on an intranet. Only one
paragraph of text will be saved at any one time and the idea is that only
one person will ever actually edit this text, via a password protected area
of the website and possibly on a daily basis and the results will be
displayed on the home page of the intranet as "Daily Notices".

The person entering the text will see the previous day's Notice at the top
of the screen, and I am doing this with <!--#INCLUDE FILE="notices.txt"-->,
which works fine the first time they open the page. Underneath the "old"
notice will be a <FORM> with one text box for them to fill in, and a SUBMIT
button to submit the new text. When they click the SUBMIT button, the text
gets saved immediately to notices.txt.

It is at this point that I want the newly saved text to be displayed once
again at the top of the (refreshed) page, with a black <FORM> underneath,
giving them the opportunity to read what they wrote and possibly change it
if they wish.

I seem to be able to achieve this only if I have a "back" button (<a
href="notices.asp">Back</a> which just totally reloads the page and then
seems to read in the newly entered text. The form says <FORM
action="notices.asp" method="post">.

I'm not sure why the SUBMIT button does not do the same "job" as the back
button and totally refresh the page with the newly entered and saved text.
I'm confused.

I hope this explains it a bit better.


Formatting is not a problem, I just want to display the most currently
entered text.

This text will then also be displayed on the home page of the intranet.

Laura

[snip]

Are you using a <textarea> to enter the text?

If so, just have to notices.txt data in on page load.

This allows them to:
a) see what it contains;
b) allows them top modify it.

No Back button needed.

( include a "type=reset" button.)
 
L

laura

Hi,
Are you using a <textarea> to enter the text?
If so, just have to notices.txt data in on page load.

Yes, displaying text in <textarea>, not sure what you meant by the next
sentence, I guess it was something line "add" notices.txt... This would
work, but I really wanted to "display" what had been added to the text file
before the user moved on - it would act as a confirmation. I just do not
understand why the <!--#INCLUDE PAGE--> does not re-display the newly
entered text when the page is (apparently) refreshed. I actually want to
eliminate the need for the Back button and have the page completely refresh
and show the newly entered data.

Laura

McKirahan said:
laura said:
Thanks for your swift reply.

After I sent the post, I realised I had not been too clear.. my
apologies.

notices.txt will be on the server. It's going to be on an intranet. Only one
paragraph of text will be saved at any one time and the idea is that only
one person will ever actually edit this text, via a password protected area
of the website and possibly on a daily basis and the results will be
displayed on the home page of the intranet as "Daily Notices".

The person entering the text will see the previous day's Notice at the
top
of the screen, and I am doing this with <!--#INCLUDE FILE="notices.txt"-->,
which works fine the first time they open the page. Underneath the "old"
notice will be a <FORM> with one text box for them to fill in, and a SUBMIT
button to submit the new text. When they click the SUBMIT button, the
text
gets saved immediately to notices.txt.

It is at this point that I want the newly saved text to be displayed once
again at the top of the (refreshed) page, with a black <FORM> underneath,
giving them the opportunity to read what they wrote and possibly change
it
if they wish.

I seem to be able to achieve this only if I have a "back" button (<a
href="notices.asp">Back</a> which just totally reloads the page and then
seems to read in the newly entered text. The form says <FORM
action="notices.asp" method="post">.

I'm not sure why the SUBMIT button does not do the same "job" as the back
button and totally refresh the page with the newly entered and saved
text.
I'm confused.

I hope this explains it a bit better.


Formatting is not a problem, I just want to display the most currently
entered text.

This text will then also be displayed on the home page of the intranet.

Laura

[snip]

Are you using a <textarea> to enter the text?

If so, just have to notices.txt data in on page load.

This allows them to:
a) see what it contains;
b) allows them top modify it.

No Back button needed.

( include a "type=reset" button.)
 
J

Joe Iano

I think your problem is that include files are processed before scripts. So
first the submitted page reads the include file, which still contains the
old text, then it runs the script, which updates the include file.

I'm doing a page which gathers some text in the form of a text box in a
<form>. This text is saved to a text file, notices.txt and I want to be able
to display the saved text on the page, as soon as they click the SUBMIT
button - is this possible?

At the moment I have a hyperlink called "back" which, once they have entered
the text and they click SUBMIT, the "back" hyperlink will refresh the page
and it displays the newly entered text. However, I want to avoid them having
to press two things in order to see the text they have entered.. i.e., can
the submit button also totally refresh the page and display the newly
entered text?

Thanks
Laura TD
 
N

Neil Sandford

laura said:
I just do not
understand why the <!--#INCLUDE PAGE--> does not re-display the newly
entered text when the page is (apparently) refreshed. I actually want to
eliminate the need for the Back button and have the page completely refresh
and show the newly entered data.
The thing about #include is that it is 'pre-processed', i.e. executed before
any scripting on your page. Since your script is extracting the text from
the form, doing whatever formatting/validation you need and then saving the
text to the file, its too late - the #include has already been processed.

What I suggest in outline is something like the following (assuming the page
in question is called {dailynews.asp}:

<html>
<!--- etc --->
<%
' the page is invoked with dailynews.asp?option=update or whatever other
code functionality you need to support
' First, check if the user is authorised to edit the Daily News text.
' If so, set the variable boolIsEditor to TRUE
' etc
' Now work out what the page needs to do ...
Select Case TRIM(Request.querystring("option"))

'####################################################################
Case "update"
'#########################
' Extract the text from the form, stick it in a variable called
strCurrentText and update the text file
' etc

' Add any other cases

'####################################################################
Case else
' the default
'#########################
' read the text from the file and put it into strCurrentText
' etc

End Select
%>

<body>
<h1>Daily News</h1>
<p><% = strCurrentText %>
<%
if boolIsEditor = TRUE Then
%>
<h2>Edit daily news</h2>
<form action="dailynews.asp?option=save" method="post">
<textarea name="editfield" rows="4" id="editfield"><% = strCurrentText
%></textarea>
<!--- etc --->
</form>
<%
end if
%>
</body>
</html>

Note:

(1) You can add any other functionality you need on the page using Select
Case

(2) You can trap situations where the text file does not exist and simply
have an empty string in the variable - #include will fall over.

(3) The edit form only appears if the user is authorised to edit the text -
one page for both categories of user

Hope this helps

NeilS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,413
Latest member
ReeceDorri

Latest Threads

Top