Well, throw me on an ant hill and smear my face with Jelly !! Stakadush is right !! Thanks.. Therefore, do something like this.
<form>
<%
WHILE NOT RS.EOF
%>
<input type="checkbox" value="<%=Trim(RS("country"
)%>" name="ctry"><%=Trim(RS("country"
)%></input><br>
<%
RS.MoveNext
WEND
%>
</form>
That will list the checkboxes from your recordset and set the value property accordingly.
On the page processing the submittal, you can do something like this.
<%
dim SQL
dim m
SQL = "SELECT fields FROM table WHERE "
FOR EACH m IN Request.QueryString("ctry"
SQL = "country = '" & m & "' OR "
NEXT
strip the last OR from the SQL statement
SQL = Left(SQL,Len(SQL)-4)
SQL = SQL & " ORDER BY somefield"
%>
Now, if the user does not check any of the checkboxes, ASP will throw an error on the above code because the statement would look like this.
SELECT fields FROM table WH
Therefore, you have two choices there. You can validate client side with JavaScript to prevent the submittal unless at least one checkbox is selected, or you can validate server side in the code above and either return a message to the user or modify the SQL statement to do something different.
To do this with JavaScript, you'll need to do this back on the page with the checkboxes.
This goes between the <head></head> tags
<script Language="JavaScript">
<!--
function validate(form_obj) {
var test = 0
for (var m = 0; m < form_obj.elements.length; m++) {
if (form_obj.elements[m].name == "ctry"
{
if (form_obj.elements[m].checked == true) {
test = 1
}
}
}
if (test == 0) {
window.alert("Please check at least one country"
return false
}
return true
}
// -->
</script>
The JavaScript above will examine every element in the form, for each element with the name
ctry it will see if it's checked. If so, it sets the test value to
1 The last block evalutates the test value, alerts the user if no boxes were checked, and will fail to submit the form.
Of course, this goes in the body of the HTML
<form method="get" action="somepage.asp" onSubmit="return validate(this);">
list your checkboxes here with the name "ctry"
<input type="submit" value="Submit">
</form>