473,287 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

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

63
Hello,

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%>">
  2.  
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. %>
  12.  
Problem:
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 = "";
</script>
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 2349
jhardman
3,406 Expert 2GB
I tried using the following before the reload:
<script type="text/javascript">
document.frmPPDM.SerialNum.value = "";
</script>
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.

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

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

Similar topics

7
by: JDS | last post by:
Hi, all. I'd like to do the following, preferably *without* resorting to JavaScript: I have a long, dynamically-generated form questionnaire. Not all of the form fields are dynamically...
1
by: Monte Chan | last post by:
Hi all, I have the following codes, <script language="JavaScript"> function check_stuff(field) { alert("blank out the field now"); field.value = ""; } </script>
1
by: Joel | last post by:
Hi, How do you determine if a Date field is blank. In my Sql statement I only want records who's date field is blank (i.e. checking for only open invoices where Date_Paid = '' ...still open...
19
by: Joe Scully | last post by:
Hi all, I am having trouble with access adding a blank record to a subform everytime I finish entering data and closing the form. (The form and subform are based on the one table) When...
5
by: ChadDiesel | last post by:
My basic question is why does my print report button on my subform print a blank report when my cursor is on a blank entry line? Here is a more detailed explanation of my problem. I have a...
2
by: JohnR | last post by:
When creating an msAccess db within the Access UI itself the fields that are text are NOT padded with blanks. For example, if I have a 10 char field and put in "HI" and then when I come back to...
0
by: visionstate | last post by:
Hi there, I have a form which has 2 text boxes, a combo box and a sub form in it (which reads from a query. The query reads from the table). On load, I would like the fields in the text boxes and...
1
by: BethanyBez | last post by:
Is there any way when doing a merge with an Access Query and a columned Word doc that I can avoid blank spaces where the field is blank? I am creating a columned contact sheet with the contacts...
4
by: sparks | last post by:
I am trying to fix a database that someone did about 4 yrs ago in access97. The main table just contains demographics and is on the main form of the database. It has a subform on a tab that...
19
by: billa856 | last post by:
Hi, I have to use the table(PRODUCTION) already generated in MS Access in which all fields are of TEXT type.fields like (orderdate,palletno,customercode,itemno,pono,carto n,pcs,totalquantity)Now i...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.