473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Request.Form Problem

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
Nov 19 '05 #1
2 2819
checkbox's only postback if checked and has a value. this means a row with a
checked checkbox with a value will post two values for the same name, but an
uncheck row will only post one.

also the browser does guarantee postback order of values, so you cannot
assume it.

-- bruce (sqlwork.com)
"Roshawn Dawson" <ud****@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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

Nov 19 '05 #2
Man, I wasn't even aware of the browser issue, and I completely forgot about the fact that an
unchecked checkbox won't be returned in the form collection.

Thanks Bruce

Bruce Barker wrote:
checkbox's only postback if checked and has a value. this means a row with a
checked checkbox with a value will post two values for the same name, but an
uncheck row will only post one.

also the browser does guarantee postback order of values, so you cannot
assume it.

-- bruce (sqlwork.com)
"Roshawn Dawson" <ud****@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Christopher Brandsdal | last post by:
Hi! I get an error when I run my code Is there any other way to get te information from my form? Heres the error I get and the code beneath. Line 120 is market with ''''''''''''Line...
5
by: Wayne Wengert | last post by:
I am trying to use Request.Form to differentiate between when a page containing a form is first loaded and when it is reloaded as a result of the user clicking on the Submit button. Things are not...
2
by: Harag | last post by:
Hi All Using: JScript IIS 5 I have a problem in the following code: // The next 4 lines display exactly what was typed in the text boxes. out("<br>Request.Form="+...
5
by: Paxton | last post by:
I created an html email containing a form whose method is POST. The form is posted to an asp page for processing, but no values are retrieved. So I response.write all the Request.Form fields, and...
5
by: Jack | last post by:
Hi, I am trying to get a thorough understanding of a code where a addition or deletion of records can be done from a list of records. For addition part of the form, data is being obtained from set...
14
by: Harry Keck | last post by:
I have client side code that uses xmlhttp to make an asyncronous call to the server. This call really churns the server and can take a couple of minutes to finish. I have found that while this...
10
by: Steve Last | last post by:
Hi all, I’m using IIS6 for our college Intranet and I’m having trouble using Request.Form. Here is my code: <% If Request.QueryString("action") = "show" Then Response.Write "title: " &...
9
by: Dave | last post by:
Hi, I've been trawling the web for answer to my problem with no luck although I'm hardly alone it seems! Below is the generated source for an ASP page that posts a value called 'album' to...
5
by: =?Utf-8?B?QVRT?= | last post by:
PRB JavaScript in ASP with Request.Form Please help, I'm having a problem with JavaScript in ASP, where the ASP page crashes when I try to determine if data was posted from a FORM or through a...
18
by: Thomas Lunsford | last post by:
I have inherited a set of asp pages that I now need to augment. In order to minimize changes to production code, I would like to make a "call" to an asp page from a new asp page. Existing code is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.