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

how to allow user to edit their data after their submission?

Status
Not open for further replies.

longmatch

Programmer
Nov 1, 2001
406
Dear All:
I designed two forms in my website, one for user data input, the other for browse. Recently users asked me to allow them edit their data after their submission. They need to correct incorrect data items they have submitted. I have no idea how to do it. Could I just reload the data using the data input form? or we can find other way to do it. This is a real challenge for me. Need help.

Thanks in advance

Haijun
 
I'm not quite sure how involved to get but it sounds like you just need to retrieve the data and pre-populate the form if data was returned. In your asp(?) page that has the form in it you'll need to:

Open a connection to the data source.
Get the data (probably in a recordset).
Set variable to the recordset data and put those variables in the form elements value attribute.

Here is some quasi code:

Set cn = Server.CreateObject("ADODB.Connection")
cn.Open "data source name goes here"
sql = "SELECT * FROM some table name here "
Set rs = cn.Execute(sql)
strName = rs("record name here")

<form>
<input type=&quot;text&quot; value=&quot;<%=strName%>&quot;>
</form>

If its the users first visit there will be no data but if any data exists it will be pre-filled when they load the page.

Hope this helps
 
Thank you for your quick response.
I have set up a page to allow users to review their data in the table format. Do you think it is possible for me to write code to allow users to click the related field link (record number) to pop up this record.


Thanks

Haijun
 
What do you mean by &quot;pop up this record&quot;? If I'm understanding the question you want them to be able to edit this data. Why not make the page you mentioned that has the data in a table format contain form fields with the data in them rather than view only?
 
What is your process now? Are you using a database?

A. Make a new page with a form for updating. It will be the action for the data input form. Put logic in it to determine whether it was called from the data input page, from itself, or from the browse page.
B. When it is called from the data input page, store the new data, then display the form with values filled in.
C. When it is called from itself update the existing data, load the updated values and display the form with the new values.
D. When it is called from the browse page, load the current values and display the form with values filled in.
E. Put a link to the update page on the browse page.


=======The data input page.==================
Code:
<form action=&quot;update.asp?task=add&quot;>
 . . .


=======The update page.======================
Code:
<%
if(Request.Form(&quot;task&quot;) == &quot;add&quot;){
   //Add new data to database.
}

if(Request.Form(&quot;task&quot;) == &quot;update&quot;){
   //Update database.
}

//Load data from database.
varName = rsGet(&quot;name&quot;).value;
%>
<!-- Build the form with values filled in. -->

<form action=&quot;update.asp?task=update&quot;>
  <input type=&quot;text&quot; value=&quot;<% varName %>&quot;>
</form>
 
I am sorry I did not state my question more clear.
The users use my datainput form (there are several comboboxes in this form) to enter their data. Then they can browse their data in a table format. I would like to put a link in the recordNumber field, in order for users to be able to click the link. After their clicking, I prefer to put the data back to the datainput form for user's editing.

Thanks

Haijun
 
Build the links in the browsing table with the primay key in the querystring. Use the primary key to retrieve the data to populate the update form.

================A link in the browsing page =========
varRecordKeyValue = rsGet(&quot;key_column&quot;).value;


varRecordNumber = loop counter where you build the browsing table.
<a href=&quot;update.asp?record=<%= varRecordKeyValue %>&quot;><%= varRecordNumber %></a>



================Retrieve data in the update page =========

varRecordKeyValue = Request.Form(&quot;record&quot;);

sql = &quot;SELECT * FROM some table name WHERE key_column=&quot; + varRecordKeyValue
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top