Forms and arrays - comparing values from one field to another

Discussion in 'ASP General' started by Adrienne Boswell, Sep 28, 2006.

  1. I have a form which I am letting the user enter more than one event at
    a time. I need to check whether one date is less than another. If the
    display to date is earlier than the event date, then of course that's
    an error.

    I am getting values like:
    areaevent_display_from: 09/29/2006, 09/209/2006
    areaevent_display_to: 09/29/2006, 08/29/2006

    I could say:
    if areaevent_display_toarr(1) < areaevent_displayfromarr(1) then
    'error
    end if

    However, because I am looping through the form collection, and then
    doing for each fields value, I'm not assigning arrays, so I can't do
    the above. Any ideas?

    Below is the relavent bit of my code (there are more fields):

    <%
    For ix = 1 to Request.Form.Count
    field = request.form.key(ix)
    inputvalue = request.form.item(ix)
    y = 0
    if isrequired(field) then
    for each values in split(inputvalue,", ")
    if trim(values) = "" then
    call requiredthing
    end if
    y = y + 1
    if cint(numforms) < y then
    exit for
    end if
    next
    end if
    next

    areaevent_from = date() & ", " & date() & ", " & date() & ", " & date()
    & ", " & date() & ", " & date() & ", " & date()
    areaevent_to = date()+30 & ", " & date()+30 & ", " & date()+30 & ", " &
    date()+30 & ", " & date()+30 & ", " & date()+30 & ", " & date()+30
    event_date = date() & ", " & date() & ", " & date() & ", " & date() &
    ", " & date() & ", " & date() & ", " & date()
    areaevent_display_text = "Name of Event, Name of Event, , , , "

    areaevent_fromarr = split(areaevent_from,", ")
    areaevent_toarr = split(areaevent_to,", ")
    event_datearr = split(event_date,", ")
    areaevent_display_textarr = split(areaevent_display_text,", ")

    sub requiredthing

    thefield = field & y
    required = dorequired(required,thefield)

    end sub

    function dorequired(current, field)
    if instr(current,field) > 0 then
    'do nothing it's already there
    else
    if current <> "" then
    dorequired = current & ", " & field
    else
    dorequired = field
    end if
    end if
    end function
    %>
    <form method="post"
    action="<%=Request.ServerVariables("SCRIPT_NAME")%>?<%=makeqstring(qstring)%>">
    <% for i = 0 to noforms %>
    <div class="goldilocks">
    <label for="event_date" id="eventdate<%=i%>1">Event Date:</label>
    <input type="text" id="event_date<%=i%>" name="event_date"
    value="<%=event_datearr(i)%>" size="10" /><br />
    <label for="areaevent_display_from<%=i%>"
    id="areaevent_display_from<%=i%>1">Display From: </label> <input
    type="text" id="areaevent_from<%=i%>" name="areaevent_from"
    value="<%=areaevent_fromarr(i)%>" size="10" /><br />
    <label for="areaevent_display_to<%=i%>"
    id="areaevent_display_from<%=i%>1" style="float:none;
    width:7em">Display To: </label> <input type="text"
    id="areaevent_to<%=i%>" name="areaevent_to"
    value="<%=areaevent_toarr(i)%>" size="10" /> br />
    <label for="areaevent_display_text<%=i%>"
    id="areaevent_display_text<%=i%>1">Event Heading:</label> <input
    type="text" name="areaevent_display_text"
    id="areaevent_display_text<%=i%>"
    value="<%=areaevent_display_textarr(i)%>" size="40" maxlength="100"
    <%if Request.ServerVariables("REQUEST_METHOD") ="GET"
    then%>onfocus="if(this.value == '<%=areaevent_display_textarr(i)%>')
    this.value = '';"<%end if %> /><br />
    </div>
    <% next %>
    <input type="submit" value="Submit">
    </form>

    Thanks in advance for any assistance.

    --
    Adrienne Boswell at work
    Administrator nextBlock.com
    http://atlas.nextblock.com/files/
    Please respond to the group so others can share
    Adrienne Boswell, Sep 28, 2006
    #1
    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. Replies:
    6
    Views:
    281
  2. Tradeorganizer
    Replies:
    3
    Views:
    142
    Tradeorganizer
    Feb 7, 2007
  3. NotGiven
    Replies:
    6
    Views:
    131
    oeyvind toft
    Sep 5, 2004
  4. Replies:
    2
    Views:
    93
    Dr John Stockton
    Jul 28, 2006
  5. jr
    Replies:
    3
    Views:
    405
Loading...

Share This Page