Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > for i in Request.From problem

Reply
Thread Tools

for i in Request.From problem

 
 
Harag
Guest
Posts: n/a
 
      08-17-2004
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="+ Request.Form("Box1").Item);
out("<br>Request.Form="+ Request.Form("Box2").Item);
out("<br>Request.Form="+ Request.Form("Box3").Item);
out("<br>Request.Form="+ Request.Form("Box4").Item);
out("<br>typeof="+ typeof Request.Form); //returns "object"


// Problem here
for (var i in Request.Form) {
out('Element Text:' + Request.Form(i).Item);
}

[snipped rest]


My Problem is that the for loop is not going through each element of
the form and displaying. it just seems to skip those 3 line and
continues with the code, no errors and no text. The values are stored
in the form elements as the 5 lines of output above clarifies this
fact.

Can anyone spot the problem please???

Thanks.

Al.

 
Reply With Quote
 
 
 
 
Harag
Guest
Posts: n/a
 
      08-17-2004
On Tue, 17 Aug 2004 12:08:47 GMT, "Andrew Urquhart"
<(E-Mail Removed)> wrote:

>*Harag* wrote:
>> Hi All
>>
>> Using: JScript
>> IIS 5
>>

>[snip]
>
>> // Problem here
>> for (var i in Request.Form) {
>> out('Element Text:' + Request.Form(i).Item);
>> }

>
>[snip]
>
>> Can anyone spot the problem please???

>
>I don't think Request.Form is enumerable in that way, here's the version
>I use:
>
>function EnumeratePostData() {
> var objO = [];
> for (var e = new Enumerator(Request.Form); !e.atEnd(); e.moveNext()) {
> var key = e.item();
> var count = Request.Form(key).Count;
> for (var i=1; i<=count; ++i) {
> objO.push(Server.HTMLEncode(key) + "=" +
>Server.HTMLEncode(Request.Form(key).Item(i)));
> }
> }
> return objO.join("\r\n");
>}




for (var e = new Enumerator(Request.Form); !e.atEnd(); e.moveNext())


Cool the above works a treat now. thanks.

(heads off to read up on Enumerator)

Al.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem problem problem :( Need Help Mike ASP General 2 05-11-2004 08:36 AM



Advertisments