Sean
|
| Posted: 07/16/2003, 3:48 PM |
|
I need a way to allow multiple checkbox inserts into a single record similar to this article: http://www.gotocode.com/art.asp?art_id=302&
I am using ASP, CCS 2.1 and Access 2000. I am pulling from a table called Counties and I want a user to be able to check one or multiple counties and have it insert into the record like below.
Checkbox List
HA [/] FB [ ] GV [/] BR [ ] MG [/]
Record insert
HA, GV, MG
Can this be done in ASP? Is there a better way to do this?
Thanks.
|
|
|
 |
designfirm.ca
|
| Posted: 08/06/2003, 6:36 PM |
|
I just pasted this HTML code below on how to do multiple checkboxes. Since this site has no preview !!! I have no idea how this page is going to format when I hit the reply button.... Make sure the second Javascript code is after the body tag on the end of page or errors will happen since the checkboxes must load before setting values (you could use onload to a second function in body tag).
How it works (just store zeros and ones (e.g. 10100010010) in field, simple!
<script language="JavaScript">
function getcheck(checked){
txt = '';
for (i = 0; i < document.form1.checkbox.length; i++){
txt+=Number(document.form1.checkbox.checked);
}
document.form1.fldName.value=txt;
}
</SCRIPT>
<body>
<form name="form1">
<table border="0" width="200" cellspacing="0" cellpadding="0">
<tr>
<td><input type="checkbox" name="checkbox" value="0" onclick="getcheck(this.checked);"></td>
<td width="100%">Morning</td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox" value="0" onclick="getcheck(this.checked);"></td>
<td width="100%">Afternoon</td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox" value="0" onclick="getcheck(this.checked);"></td>
<td width="100%">Evening</td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox" value="0" onclick="getcheck(this.checked);"></td>
<td width="100%">Any Time</td>
</tr>
<tr>
<td colspan="2"><input type="text" name="fldName" maxlength="50" value="1010" size="20"></td>
</tr>
</table></form1>
</body>
<script language="JavaScript">
ck=document.form1.fldName.value
for (i = 0; i < document.form1.checkbox.length; i++){
document.form1.checkbox.checked=Number(ck.charAt(i));
}
</SCRIPT>
|
|
|
 |
|