468,505 Members | 1,790 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,505 developers. It's quick & easy.

How to blank out a field before re-loading the page


I have a situation using VBScript where I read a table of valid serial numbers and if the serial number cannot be found, blank out the serial number field, display an error message, and reload the page. Listed below is some of the code which would be issued after the valid serial number table is read. ( The error message display is left off since that code is working.)

Serial # field:
Expand|Select|Wrap|Line Numbers
  1. <input type="text" name="SerialNum" id="SerialNum" MaxLength="11"  value="<%=strSerialNum%>">
Code used after valid serial number table read:
Expand|Select|Wrap|Line Numbers
  1. <%
  2. If rec.EOF Then  
  3.   (Display Error Message Code here.)
  4.   strSerialNum = "" 
  5. %>
  6. <script>
  7.    window.location.reload(); 
  8.  </script>
  9. <%
  10.  End If
  11. %>
The problem is that blanking out the variable strSerialnum is not blanking the SerialNum field and after the reload is issued (after a bad serial number is entered), the code at the top of the program:
strSerialNum = Request.Form("SerialNum")
reloads the bad serial number.

I tried using the following before the reload:
<script type="text/javascript">
document.frmPPDM.SerialNum.value = "";
but got an error indicating a null object. Does anyone have any ideas, how to blank out the SerialNum field before doing the reload of the page?
Mar 27 '10 #1
2 2223
3,405 Expert 2GB
I tried using the following before the reload:
<script type="text/javascript">
document.frmPPDM.SerialNum.value = "";
This is definitely the right approach, I'm not a Javascript expert, but i would bet your javascript syntax is slightly off. maybe something like getelementbyid, or document.all...

Anyway, in your previous approach, you set the value of the input from the variable, then clear the variable and submit the form, but the form input still has the value set, that's why you need to do the javascript step to clear the form input. The other option would be to check for validity BEFORE you put the number in the form input.

Mar 28 '10 #2
Thanks for the response. I tried re-arranging a few lines of code and everything seems to be working.
Mar 30 '10 #3

Post your reply

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

Similar topics

1 post views Thread by Monte Chan | last post: by
1 post views Thread by Joel | last post: by
19 posts views Thread by Joe Scully | last post: by
reply views Thread by visionstate | last post: by
reply views Thread by NPC403 | last post: by
3 posts views Thread by gieforce | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.