12-23-04 10:59 PM
MN wrote:
> Hello all -
>
> I have done ASP for a while but never found a quick way to handle
> this issue.
>
> I have 8 dropdown boxes. Is there an easy to check that only 1 has
> selected 'Yes' and the others are 'No' without checking infinite
> combinations?
>
> I usually do this with alot of coding for the combinations.
>
> Any thoughts are appreciated.
> MN
Dropdowns with only two choices? Why not radio buttons?
Assuming you've given them names to make them easily distinguishable from
the rest of the data elements in your form (say: dd1,...dd8), you can simply
loop through them. Something like this:
function OnlyOneYes()
dim i,curval, newval, bResult
curval="No"
bResult=true
for i=1 to 8
newval=request.form("dd" & i)
if newval = "Yes" then
if curVal = "Yes" then
bResult=false
exit for
else
curVal = newVal
end if
next
if curval = "Yes" then
OnlyOneYes=bResult
else
OnlyOneYes=false
end if
end function
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
[ Post a follow-up to this message ]
|