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

Problems updating form values from recordset values

Status
Not open for further replies.

Richey

Technical User
Aug 29, 2000
121
GB
Hi

once my users have submitted an online form i let them edit their own details by logging in with a username/password.
the details are read from a recordset, the user can change any details and click update form, which checks the validation, if successful updates the record else highlights to the user their errors to correct.
I have the details in text boxes read from the recordset such as.......................

Code:
BusinessName = objRS("BusinessName")
b = b & "<INPUT type=""text"" name=""BusinessName"" ID=""BusinessName"" size=""20"" value=""" &  BusinessName &  """ />"

thats fine but if the user updates say the BusinessName field and Address field, if the BusinessName field doesn't meet the validation (i.e. is blank) the address field loses its changes too because the text box always says
value=""" & Address1 & """
which is going to revert back to the recordset value.

so my code flow goes abit like below

any ideas ?

Code:
strSQL = "SELECT * FROM members where UserName = '" & Session("mID") & "'"
objRS.CursorType = 3 'adOpenStatic
objRS.CursorLocation = 3 'adUseClient
set objRS=ObjCon.execute(strSQL)

BusinessName = Request.Form("BusinessName")
Address1 = Request.Form("Address1")

If BusinessName = ""  Then
ErrorMsg2 = ErrorMsg2 & "Please enter your Business Name<br></br>"
end if
If Address1 = ""  Then
ErrorMsg2 = ErrorMsg2 & "Please enter a Address<br></br>"
end if

If ErrorMsg2 = "" Then
'update form
Response.Redirect "thank you page"
else
end if

If ErrorMsg2 <> "" Then
b = "<p><br></br><font color=""#FF0000"">" & ErrorMsg2 & "</font></p>"
else
end if

BusinessName = objRS("BusinessName")
Address1 = objRS("Address1")

b = b & "<FORM action=""web.asp?page=621"" METHOD=""post"" name=""formUpdate"">" 
b = b & "<INPUT type=""text"" name=""BusinessName"" ID=""BusinessName"" size=""20"" value=""" &  BusinessName &  """ />" 
b = b & "<INPUT type=""text"" name=""Address1"" ID=""Address1"" size=""20"" value=""" &  Address1 &  """ />"

 
i would suggest that you use javascript to alert the users for any error messages...this way you wont lose the values entered by the user in other fields...something like this
Code:
<%If BusinessName = ""  Then%>
<script language="javascript">
alert("please enter the business name")
</script>
<%end if%>

-DNG
 
thanks' but can't use javascript because of accessibility issues i.e. the user may turn off allow scripting in their browser settings. a pain i know !
 
you are getting confused here with server and client processing...when the client updates the new values, they are not inside the database yet because you havent processed it yet as you are still in the error checking stage...so you need some kind of client side script that holds the updated values and retains them...

-DNG
 
oh ok

I've got

BusinessName = Request.Form("BusinessName")
Address1 = Request.Form("Address1")
etc
etc

which is what values are used when the update happens (validation met), i.e. server-side processing............its just they are getting overwritten by the recordset values...........

could i use an if then else statment on the value = so if there is an error it uses request.form ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top