INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

sending data

sending data

(OP)
Hello everyone.

I am going to try and explain what I need, what the code is doing, and how I may injure myself due to the frustration.

I have a table of records returned from my query of the database table. This is fine and dandy. I am wanting to have some dropdown boxes on the table for the purpose of updating a person's status. I have placed a dropdown list for this purpose.
The problem is when this gets submitted, it sends the valuses for all records returned and not just the one I wish to update. I have the "ID" in a hidden field so the asp processing page knows which record should be updated but when I response.write id on that page, it shows every id returned fopr that query.

Here is the code

CODE

<form name="form1" action="statuschangeasp.asp" method="post">

	<tr style bgcolor="<%=rowcolor%>">
		<td class="auto-style2" ><%=orders1.fields.item("id").value%></td>
		<td class="auto-style2" >
		<span id="c10_ctl">
		
		<select  onChange="document.form1.submit()" name="change_">
		<option selected="<%=orders1.fields.item("istatus_").value%>" value="<%=orders1.fields.item("istatus_").value%>"><%=orders1.fields.item("istatus_").value%></option>
		
		<option value="Shipped">Shipped</option>
		<option value="Sent">Sent</option>
		<option value="paid1">Paid PayPal</option>
		<option value="paid2">Paid Check</option>
		<option value="received">Received</option>
		<option value="processing">Processing</option>
		<option value="processed">Processed</option>
		<option value="returned">Returned</option>
		<option value="Pending">Pending</option>
		</select>
			<input name="id" type="hidden" value='<%=orders1.fields.item("id").value%>'/>
			
			</span>
			</td>
		<td class="auto-style2" ><%=orders1.fields.item("tracking_").value%></td>
		<td class="auto-style2" ><%=orders1.fields.item("first_").value%></td>
		<td class="auto-style2" ><%=orders1.fields.item("last_").value%></td>
		<td class="auto-style2" ><%=orders1.fields.item("state_").value%></td>
		<td class="auto-style2" ><%=orders1.fields.item("email_").value%></td>
		<td class="auto-style2" ><%=orders1.fields.item("phone_").value%></td>
		<td class="auto-style2" ><%=orders1.fields.item("mod1_").value%></td>
	</tr>
	
<% 
irowcolor = irowcolor + 1
orders1.movenext
loop
else
%>
</form> 

the result should be whatever the change is on the dropdown, along with the id for that record. this is what the response.write for the status_ and the id look like.

CODE

processing, shipped, pending, shipped, pending, shipped, shipped, shipped, shipped, shipped, shipped, shipped, pending, pending, pending93, 100, 103, 105, 106, 108, 109, 115, 119, 120, 121, 123, 126, 127, 128 


any ideas?

RE: sending data

(OP)
If this should be asked in a different forum, please let me know that as well.

RE: sending data

The select control has the same name (change_) on each row, so when you request it, it's giving you the values it finds on every row. So give each select a different name. Since you say you will know the id from a hidden field, attach the ID number to the name of each select like below, then request "change_" plus the ID number.

<select onChange="document.form1.submit()" name="change_<%=orders1.fields.item("istatus_").value%>"> 

RE: sending data

(OP)
I understand what you are saying but I do not follow, if you will.

Each row contains the form, yes, but it is only getting submitted from a single row containing specific records from the loop. So I would think that the values of the form were based on the record in the loop and not all of the records.

I am confused.
Anyhoo, I have tried your idea and it brings up a question.

If I change the name to name="change_<%=orders1.fields.item("istatus_").value%>" How do I capture this on the processing page?

CODE

statuschange_ = request.form("change_")&id 
does not seem to work.

RE: sending data

(OP)
Also, this still sends all of the "id" from the hidden field as well.

This just seems so basic and I cannot figure it out. I have done this in the past but cannot remember.

RE: sending data

(OP)
I am thinking about this and I believe it is the form name being the issue. The "onchange" is submitting each form with that name. I think I need to change the form name to be dynamic with record and only submit that.

possible?

RE: sending data

No, you have one row per database record. Each row (TR tag) contains 9 cells (TD tags), the second of which is a dropdown (SELECT tag) that is supposed to relate to the status of that record. Presumably you are enclosing all these rows (TR tags) inside a table (TABLE tag... which I don't see here). And that entire table would be inside one form (FORM tag). The code you posted is either incorrect or incomplete.

Given that scenario, every time you change any of the SELECT boxes to a different option, the ENTIRE form is being submitted (onChange="document.form1.submit()"). At this time, you can request values any or all the form fields you created.

How do I capture this on the processing page?

statuschange_ = request.form("change_" & id)

RE: sending data

Something like this is what I'm referring to. This is not working code, just giving you an idea of what i mean

CODE

<form name="form1">
<table>

<%sql = "SELECT * FROM myorders WHERE something = true"
orders1.Open sql, Connectionstring
Do while not orders1.eof
%>
   <TR>
      <TD><%=orders1.fields.item("id").value%>
      <TD><select onChange="document.form1.submit()" name="change_<%=orders1.fields.item("id").value%>">
         <option>Shipped
         <option>Sent
         <option>etc
         </select>
<% 
   orders1.movenext
loop
orders.close
%>   

</table>
</form> 

RE: sending data

Oh ok....

Give your hidden field an ID:
<input id="statusid" name="statusid" type="hidden" value='<%=orders1.fields.item("id").value%>'/> 

Change your onchange to:
onchange="document.getElementById('statusid').value='<%=orders1.fields.item("id").value%>';document.form1.submit();" 

I'm doing this quickly so sorry in advance if I'm getting anything wrong; not tested, but this should store the ID number of the changed select box in the hidden value (that I renamed statusid). Again, typing fast but something like this should work:
statuschange_ = request.form("change_" & request.form("statusid")) 

RE: sending data

Actually, for the hidden field:
<input id="statusid" name="statusid" type="hidden" value=""> 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close