Multiple checkbox on client sample <%@ Language=VBScript %> <HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> </HEAD> <title>Multiple checkbox on client sample</title> <BODY> <!-- Author: Adrian Forbes --> <% strconn = "Driver={SQL Server};Description=sqldemo;SERVER=127.0.0.1;UID=LoginID;PWD=Password;DATABASE=Database_Name set conn = server.createobject("adodb.connection") conn.open strconn set objRS = createobject("ADODB.Recordset") objRS.Open "select ID, strParent, bitEnabled from Parents", strconn %> <p> List of all parents in database, those that are enabled are checked. </p> <% iCount = 0 while not objRS.EOF lID = clng(objRS("ID")) iCount = iCount + 1%> <input type=CHECKBOX ID=chkParent<%=iCount%> name=chkParent<%=iCount%> value="<%=objRS("ID")%>"<%if objRS("bitEnabled") then Response.Write " CHECKED" end if%>><%=objRS("strParent")%><br> <% objRS.MoveNext wend objRS.Close set objRS.ActiveConnection = nothing set objRS = nothing %> <input type=HIDDEN ID=txtCount value="<%=iCount%>"> <p><input type=BUTTON value="Select" onClick="ShowSelected()"></p> <script language=VBScript> sub ShowSelected for i = 1 to document.all("txtCount").value set objChk = document.all("chkParent" & i) if objChk.Checked then msgbox "Checkbox " & i & " with value " & objChk.Value & " is checked" else msgbox "Checkbox " & i & " with value " & objChk.Value & " is not checked" end if next end sub </script> </BODY> </HTML> |