Check og selectboxe
HejsaJeg har flg. kode som lister poster med en select box og en checkbox til.
<form action="/competence/adduser.asp" method="post">
<table width="297" height="100" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th width="43%">Kompetence: </th>
<th width="43%">Beskrivelse: </th>
<th width="43%">Niveau: </th>
<th width="43%">Valgt: </th>
</tr>
<tr>
<td colspan="4"> </td>
</tr>
<%
Call Connection()
SQL="SELECT * FROM Competence ORDER BY CompetenceName"
SET strSQL = RS.Execute(SQL)
SQLA="SELECT * FROM CompetenceLevel ORDER BY ID"
SET strSQLA = RS.Execute(SQLa)
color = "1"
do while not strSQL.EOF
If color = "1" Then
bgcolor = "6699FF"
color = "2"
ElseIf color = "2" Then
bgcolor = "99CCFF"
color = "1"
End If
%>
<tr bgcolor="#<%=bgcolor%>">
<td width="43%"><%=strSQL("CompetenceName")%></td>
<td width="43%"><%=strSQL("CompetenceDescription")%></td>
<td width="43%">
<select name="CompetenceLevel" title="Vælg kompetence niveau">
<option value ="" title="Vælg niveau"> Væg niveau</option>
<%
do while not strSQLA.EOF
%>
<option value ="<%=strSQLA("CompetenceLevel")%>" title="Vælg niveau">
<%=strSQLA("CompetenceLevel")%>
</option>
<%
strSQLA.MoveNext
Loop
strSQLA.MoveFirst
%>
</select>
</td>
<td width="43%"><input type="checkbox" name="valgt" value="<%=strSQL("Id")%>"></td>
</tr>
<%
strSQL.MoveNext
Loop
Call CloseCon()
%>
</table>
<input type="submit">
<table width="100">
<tr>
<td width="84">
</td>
</tr>
</table>
</form>
Hvordan får jeg fat i indholdet af selectboxen, når der er checked i checkboxen ?
Har prøvet med det her:
mitarray = Split(Request.Form("valgt"),",")
Tal = 1
For i = 1 To ubound(mitarray)+1
SQL = "INSERT INTO UserCompetence (UserId,CompetenceId,CompetenceLevelId) VALUES ("&Session("id")&","&mitarray(i-1)&","&Request.Form("CompetenceLevel")(i)&")"
Response.Write(SQL)&"<br>"
'RS.Execute(SQL)
Next
