Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display "Please wait..." message during server-side processing

Status
Not open for further replies.

jasonsalas

IS-IT--Management
Jun 20, 2001
480
0
0
GU
Hi everyone,

I've got a form taking in information and then passing the form field data to an ASP 3.0 script using the ASPMail component to send mail. What I've learned is that apparently ASPMail verifies that the sender and recipient e-mail addresses specified in the form fields are valid and existing. Failing this, an error message is generated and sent back to the client.

This is pretty cool, however I've found out that the processing time is quit long...about 15 seconds on average. So upon submission, the page appears to just hang, although it does eventually work. I've noticed this has confused my users.

So, what I'd like to do is be able to display a message on the form page saying &quot;Verifying your e-mail addresses...&quot; or something to that extent as the form is submitted so they'll know what's going on. I was thinking of setting the visibility of a <DIV> to true on the client-side after getting an object reference to the form (document.forms[0] and then getting the submit() method), but I'm not quite sure on the JavaScript syntax. I assume it would have to do wth the OnSubmit() event.

Got any ideas?
 
try this:


<script language=javascript>
function hiddentext() {
document.all['process'].style.visibility =&quot;hidden&quot;;
}

function submit_form() {
document.all['process'].style.visibility =&quot;visible&quot;;
document.form1.action=&quot;targetpage.html&quot;;
document.form1.submit();
}
</script>
</head>
<body onload=&quot;javascript:hiddentext();&quot;>
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<form name=form1 method=post onsubmit=&quot;submit_form()&quot;>
<tr><td colspan=2 align=center><div id=process>processing...</div></td></tr>
<tr>
<td colspan=2> <input type=submit></td>
</tr>
</form>
 
H2,

Actually, I've noticed one slight snafu...the status bar on the browser doesn't always appear, so it stays on &quot;Done&quot;, making the user think the page has finished loading. I worded the processing message in such a way as to let them know that they need to wait, but I hope this doesn't decrease usage.

p.s. I also had to comment out the following line of your JavaScript function:
document.form1.action=&quot;targetpage.html&quot;;

...and stick to having the ACTION attribute of the server-siode <FORM> tag. It wouldn't work right the other way. :)
 
I think you can change the code like this (note the colored code in the following):
1. remove the onload function, simply use the style to change the color of the &quot;process&quot; message to white, so it seems invisible, and change to red when the form is submitted.
2. add the validate code in the js function instead of using FrontPage build-in script. coz you'll find that if u do not input &quot;your name&quot; the &quot;process&quot; message is still visible.
3. add window.status to change the status (I'm not sure is it what you want)


<style> .processingMessage {font-family:Arial;font-weight:bolder;color:white;font-size:14pt;} </style>

<script language=javascript>



function submit_form() {
if (document.FrontPage_Form1.txtFromName.value == &quot;&quot;) {
alert(&quot;Please enter a value for the 'Your name' field.&quot;);
document.FrontPage_Form1.txtFromName.focus();
return false;
} else {
document.all['process'].style.color =&quot;red&quot;;
window.status = &quot;processing...&quot;;
return true;
}
}

</script>
</head>
......

<body>

......
<form method=&quot;post&quot; action=&quot;emailarticle.asp?headline=6132&quot; name=&quot;FrontPage_Form1&quot; onsubmit=&quot;return submit_form();&quot;>


remember to remove the following code:


<script Language=&quot;VBScript&quot;><!--
function FrontPage_Form1_onsubmit()
Set theForm = document.FrontPage_Form1

If (theForm.txtFromName.value = &quot;&quot;) Then
MsgBox &quot;Please enter a value for the &quot;&quot;txtFromName&quot;&quot; field.&quot;, 0, &quot;Validation Error&quot;
theForm.txtFromName.focus()
FrontPage_Form1_onsubmit = False
Exit Function
End If
FrontPage_Form1_onsubmit = True
End Function
--></script>

......
function hiddentext() {
document.all['process'].style.visibility =&quot;hidden&quot;;
}



hope it's useful for you ^^

P.S. both place in js function (document.form1.action=&quot;xxx&quot;;) or place in the <form> tag get the same result.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top