for i in Request.From problem

Discussion in 'ASP General' started by Harag, Aug 17, 2004.

  1. Harag

    Harag Guest

    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.
    Harag, Aug 17, 2004
    #1
    1. Advertising

  2. Harag

    Harag Guest

    On Tue, 17 Aug 2004 12:08:47 GMT, "Andrew Urquhart"
    <> 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.
    Harag, Aug 17, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve
    Replies:
    0
    Views:
    5,327
    Steve
    Jul 1, 2003
  2. Daniel Bass
    Replies:
    2
    Views:
    3,708
    dave wanta
    Jul 4, 2003
  3. Brian Birtle
    Replies:
    2
    Views:
    2,013
    John Saunders
    Oct 16, 2003
  4. Replies:
    1
    Views:
    6,270
    Ryan Stewart
    Dec 29, 2004
  5. norton
    Replies:
    4
    Views:
    230
    Dave Anderson
    Aug 13, 2004
Loading...

Share This Page