Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Forms and arrays - comparing values from one field to another

Reply
Thread Tools

Forms and arrays - comparing values from one field to another

 
 
Adrienne Boswell
Guest
Posts: n/a
 
      09-28-2006
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

 
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
javascript validation for a not required field, field is onlyrequired if another field has a value jr Javascript 3 07-08-2010 10:33 AM
comparing values of field and inserting data based on comparision to third filed Tradeorganizer ASP General 3 02-07-2007 05:13 AM
comparing values from two different arrays and finding the diff psmahesh@gmail.com Javascript 2 07-28-2006 12:26 PM
comparing field data from previous field in loop with null values abbylee26@hotmail.com ASP General 6 02-15-2006 01:59 PM
how to choose one field and automatically show sub-selections in another field? NotGiven Javascript 6 09-05-2004 04:14 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57