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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refresh Page

Status
Not open for further replies.

HotBob

Programmer
May 26, 2006
37
GB
Hi there, I am saving a page with a few items back to a database.

However, when I overwrite my old values and press save the values in my text box go back to the previous value.

Then if i press F5 the page refreshes and the new values appear. However, I want to see the new values straight away.

Any ideas?

I think my form Action is the problem.

Code:
<HTML>
	
	<HEAD>
		<title></title>
		<meta content="CRE InSite - " name=Description />
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">	
		<!--#include virtual="/includes/styles.asp"-->
		
		<script language="JavaScript">	
		function setfocus()
		{
		document.forms[0].submitID.focus()
		}
		
		
		</script>	
		
		<script language=" JavaScript" ><!-- 
			function MyReload() 
			{ 
			window.location.reload(); 
			} 
			//--></script> 
		
		<script> 
		function refresh() 
		{ 
			window.location.reload(); 
		} 
		</script> 
	</HEAD>
	<%
	Public bolExist, strBatterySerialNo, bitConfirmed

	%>
	<!-- #include virtual="/includes/adovbs.inc" -->
	<!-- #include virtual="/includes/DellConnect.asp" -->
	
	
	<div style="DISPLAY: none">CRE InSite</div>
	<body onLoad="document.search.Serial.focus();" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0" marginwidth="0" marginheight="0" >  <!--OnLoad="document.search.Signature.focus();/-->		
	
<!-- header starts here /-->

	<!--#include virtual="/includes/header.asp"-->

<!-- header ends here /-->
<!-- content goes here /-->
			
			<table height="100%" cellSpacing="0" cellPadding="0" width="105%" border="0">
				<tr vAlign="top" height="*">					
				  <td valign="top" width="*">
<!-- BREADCRUMB CONTROL -->
					<table width="740" border="0" cellspacing="0" cellpadding="0" class="breadCrumbBG">
						<tr>
							<td height="21" class="bodyText"><img src="/images/template/spacer.gif" width="5" height="1" alt="" border="0" /><img src="/images/template/arrowLeft36c.gif" width="3" height="6" alt="" border="0" />&nbsp;<a href="/" class="breadcrumbNav">Home</a></td>
						</tr>
						<tr>
							<td height="1" bgcolor="white"><img src="/images/template/spacer.gif" width="5" height="1" alt="" border="0" /></td>
						</tr>
					</table>
<!-- / BREADCRUMB CONTROL -->
					<table cellSpacing="0" cellPadding="0" width="740" height="100%" style="border-collapse: collapse" bordercolor="#111111">
					<tr>
						<td width="5" bgcolor="#eeeeee" align="left" valign="top"><img src="/images/template/spacer.gif" width="5" border="0"></td>
						<td width="130" bgcolor="#eeeeee" align="left" valign="top"><p>&nbsp;</p>
					      
						<p>
                        <!--webbot bot="Navigation" S-Orientation="vertical" S-Rendering="graphics" S-Type="children" B-Include-Home="FALSE" B-Include-Up="TRUE" startspan --><!--webbot bot="Navigation" endspan i-checksum="0" --></p>
						</td>
					  <td width="605" align="left" valign="top">
<!-- middle cell for main content starts here-->			
	  
					  <table width="100%" cellspacing="5" cellpadding="5">
                        <tr>
                          <td align="left"  width="100%" height="20" valign="top" class="pageTitle">Dell Laptop Batteries </td>
                        </tr>
						<tr>
                          <td align="left"  width="100%" valign="top" class="bodyText">
						  
						  <table width="100%" height="246" border="0" cellpadding="0" cellspacing="0">

     <tr>

          <td width="100%" bgcolor="#FFFFFF" valign="top" height="100">

                <form method="post" name="search" id="search" >
            			
				<%
				
					dim objConn, objRec

					set objConn = server.createobject("ADODB.connection")
					set objRec = server.createobject("ADODB.recordset")
					
					objconn.errors.clear
					objconn.open strConnect
										
					strSQL =  "SELECT Bat, Confirmed FROM tblBat WHERE loginID = '" & lcase(strShortUsername) & "'"
							
					objRec.open strSQL, objconn
					
					bolExist = false
					while not objRec.eof
						bolExist = true
						strBatterySerialNo =  objRec("Bat") 
						bitConfirmed = objRec("Confirmed") 
						objrec.movenext	
					wend
												
					set objRec = nothing	
					objConn.close
					set objConn = nothing
				
				%>
			<table width="500" height="37" BORDER="0">
              <tr>
                <td width="200" valign="middle"><font size="2" color="#003468"><b>Name</b></font></td>
                <td width="300" valign="middle"><font size="2"> <!--onkeypress="return entsub(document.search)"  -->
                </font>
				<%
				'response.Write(lcase(strShortUsername))	
								

				set objConn = server.createobject("ADODB.connection")
				set objRec = server.createobject("ADODB.recordset")
				
				objconn.errors.clear
				objconn.open strConnect
				
				StrSQL =  "select FirstName + ' ' + Surname AS FullName From tblPeo WHERE loginID = '" & lcase(strShortUsername) & "'"
						
				objRec.open strSQL, objconn
				
				Response.Write(objRec("Fullname"))
				
				set objRec = nothing	
				objConn.close
				set objConn = nothing
								
				%>		
				</td>
              </tr>
            </table>
            <table width="500" height="37" BORDER="0">
              <tr>
                <td width="200" valign="middle"><font size="2" color="#003468"><strong>Battery Serial Number </strong></font></td>
                <td width="300" valign="middle"><font size="2"> 
					<input TYPE="TEXT" NAME="Serial" VALUE="<%=strBatterySerialNo%>" onKeyPress="if(event.keyCode==13) {document.Search.submitID.click(); return false}" size="35">
				</font>
				</td>
              </tr>
            </table>
			<table width="500" height="37" BORDER="0">
              <tr>
                <td width="200" valign="middle"><font size="2" color="#003468"><strong>Battery Checked </strong></font></td>
                <td width="300" valign="middle"><font size="2"><input type="checkbox" name="chkBattery" id="chkBattery" value="Battery" <%If bitConfirmed = true Then response.write "checked"%>>
                </font></td>
              </tr>
            </table>
			<p></p>
			<input name="submitID" TYPE="submit" id="submitID" value="Save">
			</form>
            <p>
   		    <%
		on error resume next
		
		If trim(request.form("submitID")) = "Save" Then
						
			if request.form("chkBattery") = "Battery" then
  				strConfirmed = "1"
			else
  				strConfirmed = "0"
			end if
			
			'Detemine whether user exists in table
				
				StrSQL = "select count(*) AS [Exists] from tblBat where loginid = '" & lcase(strShortUsername) & "'"
				

				set objConn = server.createobject("ADODB.connection")
				set objRec = server.createobject("ADODB.recordset")
				
				objconn.errors.clear
				objconn.open strConnect

				objRec.open strSQL, objconn
				
				If objRec("Exists") = O Then
					bolInsert = True
				Else
					bolInsert = False
				End if
				
				set objRec = nothing	
				objConn.close
				set objConn = nothing
				
				
				
				If bolInsert = True Then
					StrSQL = "INSERT INTO tblBat (loginID, Bat, Confirmed) VALUES ('" & lcase(strShortUsername) & "','" & request.Form("Serial") & "'," & strConfirmed & ")"
				Else
					StrSQL = "UPDATE tblBat SET Bat = '" & request.Form("Serial") & "', Confirmed = " & strConfirmed & " WHERE loginID = '"  & lcase(strShortUsername) & "'"
				End if
				
				'dim objConn, objRec

				set objConn = server.createobject("ADODB.connection")
				set objRec = server.createobject("ADODB.recordset")
				
				objconn.errors.clear
				objconn.open strConnect

				objRec.open strSQL, objconn
				
				set objRec = nothing	
				objConn.close
				set objConn = nothing
				
							
		End if
		
		
		%>
   		    <br>
   
     </p>
   		  </tr>

</table>
						  
						  </td>
                        </tr>
                      </table>
					 
					  </td>						
					</tr>
					</Table>	
					</td>
				</tr>
			</table>

<!-- footer starts here -->

				<!--#include virtual="/includes/footer.asp"-->
				
<!-- footer ends here -->
	</body>
</HTML>
 
Try adding the following to the top of your page; it should prevent the page from caching the values (which I am guessing is what is happening):
Code:
<%response.Expires=-1%>

Take Care,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top