Forms and arrays - comparing values from one field to another

A

Adrienne Boswell

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.
 

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

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top