for i in Request.From problem

H

Harag

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.
 
H

Harag

*Harag* said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top