PDA

View Full Version : form submission proplem


needhelp26
09-11-2004, 11:57 PM
Can someone please tell what may be the problem? When i enter data in fileone.asp and hit the Display button to view the info in filetwo.asp, the data in shown in their respective fields but when I submit the information to the database, the information is storing like field1 =No, Yes in the same field. But 'Yes' should be in the field2.


fileone.asp
<form action="filetwo.asp" method="Post">
<table>
<tr>
<td>
Field1:</td>
<td> <Select name="field1">
<option value="Yes" Selected>Yes</option>
<option value="No">No</option>
</select></td>
</tr>
<tr>
<td>Field2:</td>
<td><select name="field2">
<option value="No" Selected>No</option>
<option vlaue="Yes">Yes</option>
</select></td>
</tr>
</table>
<br />
<input type="Submit" name="display" value="display">
</form>

filetwo.asp

<form action="fileinsert.asp" method="Post">
<%
Field1 = Request.Form("field1")
Field2 = Request.Form("field2")
%>
<table>
<tr>
<td>Field1:</td>
<td><%Response.write(field1)%></td>
</tr>
<tr>
<td>Field2:</td>
<td><%Response.write(field2)%></td>
</tr>
</table>
<br /><br />
<input type="Submit" name="Submit" value="Submit">
</form>

fileinsert.asp

Dim CN, RS, SQL

database connection

request.form for field1 and field2

recordset connection
RS.Addnew method

RS.Update
RS.Close

raf
09-13-2004, 12:21 AM
i think you left out the most important info --> the sql you use for the insert

needhelp26
09-13-2004, 12:35 AM
I am using the AddNew Method to insert to the database. I don't have any problem inserting to the database. The information is going to the database but it is not appropriate.

glenngv
09-13-2004, 08:11 AM
Do you have hidden fields for those 2 fields in filetwo.asp?

<form action="fileinsert.asp" method="Post">
<%
Field1 = Request.Form("field1")
Field2 = Request.Form("field2")
...
%>
...
<input type="hidden" name="field1" value="<%=Field1%>">
<input type="hidden" name="field2" value="<%=Field2%>">
<input type="Submit" name="Submit" value="Submit">

If yes, then you must show us how do you AddNew in fileinsert.asp.

needhelp26
09-13-2004, 11:11 PM
No. I don't have hidden fields for those two textboxes. And in filetwo.asp, I want to display the data entered in fileone.asp, that is why I am using response.write(field1) and (field2), when hit the submit button, goes to the database.


<%
RS.Addnew
RS("field1") = Request.form("field1")
RS("field2") = Request.form("field2")
RS. Update
RS.Close

Set RS = Nothing
Set conn = nothing
%>

glenngv
09-14-2004, 04:19 AM
That's exactly my point. You're doing Request.Form in fileinsert.asp but in the previous page (filetwo.asp), there are no form fields. You just display the contents of fileone.asp in filetwo.asp. You must have form fields (hidden fields in this case) in filetwo.asp in order for fileinsert.asp to retrieve them.

needhelp26
09-14-2004, 02:03 PM
Say for example, if I have 20 fields, should I have to have 20 hidden fields? I do have a lot of fields and all other fields have no problem except for these two drop downs(I have other drop downs in the same form, which works fine).Actually, what is the exact method(that is coding) for retreiving data from one page to next page. If you look at filetwo.asp, I do have Request.form and then response.write to display the information. So the Request.form brings the form field from the previous page to the next and response.write displays. should hidden fields needed?