R
Roshawn Dawson
Hi,
I seem to be having trouble using the Request.Form property. Before explaining what I'm trying to
do, have a look at my html:
<form id="Cart" method="post" action="ShoppingCart.aspx">
<table id="items" cellpadding="0" cellspacing="0">
<caption>Your Shopping Cart</caption>
<thead>
<tr>
<th scope="col"><input type="checkbox" id="allItms" onclick="javascript:checkAll2(this)" /></th>
<th scope="col">Title</th>
<th scope="col">Price</th>
<th scope="col">Quantity</th>
<th scope="col">Total</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox" name="U175XG760VMHCS" /></td>
<td><a href="Details.aspx?asin=159200878X">Maran Illustrated Mac OS X v.10.4 Tiger</a></td>
<td class="price">$14.99</td>
<td><input type="text" name="U175XG760VMHCS" maxlength="3" value="1" /></td>
<td class="price">$14.99</td>
</tr>
<tr>
<td><input type="checkbox" name="U1YOOYBVTVBOX6" /></td>
<td><a href="Details.aspx?asin=0071436820">Investing in Rental Properties</a></td>
<td class="price">$11.61</td>
<td><input type="text" name="U1YOOYBVTVBOX6" maxlength="3" value="1" /></td>
<td class="price">$11.61</td>
</tr>
<tr>
<td><input type="checkbox" name="UGNFCT3Q1NT2M" /></td>
<td><a href="Details.aspx?asin=0060765313">YOU: The Owner's Manual</a></td>
<td class="price">$15.99</td>
<td><input type="text" name="UGNFCT3Q1NT2M" maxlength="3" value="1" /></td>
<td class="price">$15.99</td>
</tr>
</tbody>
<tfoot>
<tr>
<td id="subttl" colspan="5">Subtotal: $42.59</td>
</tr>
</tfoot>
</table>
<input type="submit" value="Update" />
</form>
OK. According to the html above, each row in the table has two input elements, each having the same
name. That means that for every name attribute in the form I should get two values. Am I right?
If I'm right, then this is what I'm trying to do. I would like to retrieve from each row in the
table 1.) the name of the input elements and 2.) retrieve the value of the second input element.
For example, I'm trying to get "U175XG760VMHCS" (the name of the input elements for row #1) and "1"
(the value of the second input element for row #1)
I've tried my best to get this working in ASP.NET but to no avail. Here's my code (part of it):
Dim i As Integer
Dim sb As New StringBuilder()
For i = 0 To Request.Form("Form1").Length - 1
'test to see if one of the key's values equals "on"
If Request.Form.GetValues(i)(i).ToString = "on" Then 'the checkbox is checked
sb.Append("The name is " & Request.Form.GetKey(i) & " & the value is " & Request.Form.Get(i + 1))
End If
Next
I sure hope that someone can help me with this issue. It seems so simple, yet I can't get it done.
Help, please?!?! :-(
Thanks,
Roshawn
I seem to be having trouble using the Request.Form property. Before explaining what I'm trying to
do, have a look at my html:
<form id="Cart" method="post" action="ShoppingCart.aspx">
<table id="items" cellpadding="0" cellspacing="0">
<caption>Your Shopping Cart</caption>
<thead>
<tr>
<th scope="col"><input type="checkbox" id="allItms" onclick="javascript:checkAll2(this)" /></th>
<th scope="col">Title</th>
<th scope="col">Price</th>
<th scope="col">Quantity</th>
<th scope="col">Total</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox" name="U175XG760VMHCS" /></td>
<td><a href="Details.aspx?asin=159200878X">Maran Illustrated Mac OS X v.10.4 Tiger</a></td>
<td class="price">$14.99</td>
<td><input type="text" name="U175XG760VMHCS" maxlength="3" value="1" /></td>
<td class="price">$14.99</td>
</tr>
<tr>
<td><input type="checkbox" name="U1YOOYBVTVBOX6" /></td>
<td><a href="Details.aspx?asin=0071436820">Investing in Rental Properties</a></td>
<td class="price">$11.61</td>
<td><input type="text" name="U1YOOYBVTVBOX6" maxlength="3" value="1" /></td>
<td class="price">$11.61</td>
</tr>
<tr>
<td><input type="checkbox" name="UGNFCT3Q1NT2M" /></td>
<td><a href="Details.aspx?asin=0060765313">YOU: The Owner's Manual</a></td>
<td class="price">$15.99</td>
<td><input type="text" name="UGNFCT3Q1NT2M" maxlength="3" value="1" /></td>
<td class="price">$15.99</td>
</tr>
</tbody>
<tfoot>
<tr>
<td id="subttl" colspan="5">Subtotal: $42.59</td>
</tr>
</tfoot>
</table>
<input type="submit" value="Update" />
</form>
OK. According to the html above, each row in the table has two input elements, each having the same
name. That means that for every name attribute in the form I should get two values. Am I right?
If I'm right, then this is what I'm trying to do. I would like to retrieve from each row in the
table 1.) the name of the input elements and 2.) retrieve the value of the second input element.
For example, I'm trying to get "U175XG760VMHCS" (the name of the input elements for row #1) and "1"
(the value of the second input element for row #1)
I've tried my best to get this working in ASP.NET but to no avail. Here's my code (part of it):
Dim i As Integer
Dim sb As New StringBuilder()
For i = 0 To Request.Form("Form1").Length - 1
'test to see if one of the key's values equals "on"
If Request.Form.GetValues(i)(i).ToString = "on" Then 'the checkbox is checked
sb.Append("The name is " & Request.Form.GetKey(i) & " & the value is " & Request.Form.Get(i + 1))
End If
Next
I sure hope that someone can help me with this issue. It seems so simple, yet I can't get it done.
Help, please?!?! :-(
Thanks,
Roshawn