forms question

F

Freeserve

Hi,
I have a form with some fields and a submit button. The submit button posts
the results to itself, which are then processed. I have 2 questions:

1. Is it possible to have a series of button each of which changes one of
the items posted and then posts the form?
2. Is it possible to cause a "processing" banner to be displayed until the
page gets refreshed?

Thanks.
 
B

Bob Barrows

Freeserve said:
Hi,
I have a form with some fields and a submit button. The submit
button posts the results to itself, which are then processed. I have
2 questions:

1. Is it possible to have a series of button each of which changes
one of the items posted and then posts the form?

Sure. This is a client-side code question and should have been posted to one
of the dhtml groups, but, assuming you;ve set the form's id property to
"myForm":
1. give your textbox an id (set its id property), say id="txt1"
2. give the button that controls that textbox a unique id, say id="cmd1"
3. In a script block, create a cmd1_onclick sub if you are using vbscript,
or function if jscript. Write the code to set the textbox's value property:
myForm.txt1.value = "something"
and call the form's submit method:
vbscript:
myForm.submit
jscript:
myForm.submit()

This is your last free pass :)
In the future submit client-side code questions to the appopripriate
newsgroup and indicate which script language you intend to use.
2. Is it possible to cause a "processing" banner to be displayed
until the page gets refreshed?
There is a method which sometimes works, sometimes doesn't. It requires a
combination of server-side and client-side code:
Make sure buffering is on and then use response.flush to display your
message. Then do your processing and hide the message in the window's onload
event. Here is an example:

<%@ Language=VBScript %>
<%
Response.Buffer=true
%>
<%
if len(Request.Form("text1")) > 0 then
Response.Write "<div id=""divPrc"">Processing</div>"
Response.Flush
dim t
t=now
t=dateadd("s",3,t)
do until now > t
loop
else
//we need the div to be there - this message will never be seen
Response.Write "<div id=""divPrc"">" & "Nothing to process" & "</div>"
Response.Flush
end if
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--

function window_onload() {
divPrc.style.display="none";
/*the following line is optional - do not use this if you are submitting
to another page*/
MyForm.action=window.location;
}

//-->
</SCRIPT>
</HEAD>
<BODY LANGUAGE=javascript onload="return window_onload()">

<form id="MyForm" method="post">
Enter some text and click submit:
<INPUT type="text" id=text1 name=text1>
<INPUT type="submit" value="Submit" id=submit1 name=submit1>
</form>

</BODY>
</HTML>
 
B

Bob Barrows

Correction:
<%@ Language=VBScript %>
<%
Response.Buffer=true
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--

function window_onload() {
divPrc.style.display="none";
/*the following line is optional - do not use this if you are submitting
to another page*/
MyForm.action=window.location;
}

//-->
</SCRIPT>
</HEAD>
<BODY LANGUAGE=javascript onload="return window_onload()">
<%
if len(Request.Form("text1")) > 0 then
Response.Write "<div id=""divPrc"">Processing</div>"
Response.Flush
dim t
t=now
t=dateadd("s",3,t)
do until now > t
loop
else
//we need the div to be there - this message will never be seen
Response.Write "<div id=""divPrc"">" & "Nothing to process" & "</div>"
Response.Flush
end if
%>

<form id="MyForm" method="post">
Enter some text and click submit:
<INPUT type="text" id=text1 name=text1>
<INPUT type="submit" value="Submit" id=submit1 name=submit1>
</form>

</BODY>
</HTML>
 

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
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top