Jump to content

Updating a "Sale" Table


bsheridan

Recommended Posts

Hi,I am trying to update a table with values from three other tables. This is what is happening;I have a Client, Treatment, Staff and Sale table. So when a Client buys a Treatment from a Staff member the Sale table is updated.My page that is displayed to the Client, shows the Treatment and Staff name in a drop down menu. The Staff member selects the Treatment and the Staff member who sold the treatment to the Client. However, when i click submit, only the first record from each table is added to the Sale table. Here is the code i am trying to use:

<table border="0"><tr><td width="1000" class="bluenewshead"><b>Treatment</B></TD>x<td width="1000" class="bluenewshead"><b>Staff Member</B></TD><td width="1000" class="bluenewshead"><b>Action</B></TD><tr><form name="frm" action="insert_sale_script.asp?clientID=<%= rs3("clientID")%>&staffID=<%=rs2("staffID")%>&treatmentID=<%=rs("treatmentID")%>&clientID=<%=Session("clientID")%>" method="post" ><td width="1000" class="body"><tr><td width="1000" class="body"><select name="select" id="<%=rs2("firstName")%>" value="<%=rs2("staffID")%>" ><option value="<%=rs2("staffID")%>">Please Select</option><%'while not the end of our treatment record setdo while not rs.EOF%><option value="<%= rs("treatmentID")%>"> <%Response.Write rs("treatmentName")%></option><%' Move to the next recordrs.MoveNext' LoopLoop' move back to the first recordrs.MoveFirst%><td width="1000" class="body"><select name="select" id="<%=rs2("firstName")%>" value="<%=rs2("staffID")%>" ><option value="<%=rs2("staffID")%>">Please Select</option><%'while not the end of our staff member record setdo while not rs2.EOF%><option value="<%= rs2("staffID")%>"> <%Response.Write rs2("firstName")%></option><%' Move to the next recordrs2.MoveNext' LoopLoop' move back to the first recordrs2.MoveFirst%><td width="1000" class="body"><input type="submit" value="Add" id=submit1 name=submit1></td></tr></select></table><%'end of check of obs for displayend ifrs.Closers2.Close%>

I have a Do While loop for the Treatment and the Staff member, but the update is only taking the first record set from each table. Can you help please

Link to comment
Share on other sites

This is what you have for both of your select boxes:<select name="select" id="<%=rs2("firstName")%>" value="<%=rs2("staffID")%>" ><option value="<%=rs2("staffID")%>">Please Select</option>A few things wrong. First, you definately do not want a value for the select box, so remove the value attribute altogether. Second, for whatever reason you are setting the ID of the select boxes to be the name of a staff member. Remove the ID attribute also. Third, both select boxes have the same name, which is "select". One of them should probably be called "staffID" and one of them "treatmentID". Next, you have an option with the label "Please Select" that has a value of the staff member's first name. That just doesn't make sense. Remove the value for that first option so that the value attribute is present, but empty. To recap:<select name="staffID"><option value="">Please Select</option>...<select name="treatmentID"><option value="">Please Select</option>...You've also got a little weirdness with your form tag:<form name="frm" action="insert_sale_script.asp?clientID=<%= rs3("clientID")%>&staffID=<%=rs2("staffID")%>&treatmentID=<%=rs("treatmentID")%>&clientID=<%=Session("clientID")%>" method="post" >The form submits as post, but you have all this data on the querystring. For one thing, you have 2 variables called clientID with different values. Then you have a staffID and a treatmentID, and I assume you probably want those chosen from the select boxes instead of just passing them to the next page. So you can probably remove all of that stuff off the form action and keep it all in the form. If you want to pass other variables besides the select boxes, put them in hidden elements instead of in the querystring.<form name="frm" action="insert_sale_script.asp" method="post" ><input type="hidden" name="clientID" value="<%=rs3("clientID")%>">

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...