我正在寻找一种 Javascript 解决方案,该解决方案将根据在同一表单的其他地方选择的特定下拉值(在标准 HTML 中,由 SQL 生成)启用(在其中放置检查)表单上的复选框。我还没有写任何代码,所以现在没有任何代码可以在这里展示。20 年 4 月 8 日编辑:根据 Giuliano 的出色帮助,我决定添加我放在一起的代码(不起作用),如下所示:
<%
sSQL = "SELECT OrderTypeID, OrderTypeString FROM LookupOrderTypesII"
Set rsOrderTypes = Server.CreateObject("ADODB.RecordSet")
rsOrderTypes.Open sSQL, oConnGlobal, adOpenStatic, adLockReadOnly
iTotalRecords = rsOrderTypes.Recordcount
If iTotalRecords > 0 Then
%>
<br>
<b>SERVICE/ORDER TYPE:</b>
<br>
<script type="text/javascript">
let select = document.getElementById("cboOrderType");
let checkbox = document.getElementById("chkSkipVenueEventDetails");
select.addEventListener("change", function () {
checkbox.checked = select.value == "12|LABOR SALES/PAYMENT";
});
</script>
<select class="rounded" name="cboOrderType" id="cboOrderType">
<option value="Select One" selected>Select One</option>
<option value="-9999" <%=IfSelected(iOrderTypeID, "Not Listed-ADD Custom Type")%>>Not Listed-ADD Custom Type</option>
<%
Do While Not rsOrderTypes.EOF
iOrderTypeID = Trim(rsOrderTypes("OrderTypeID"))
sOrderTypeString = Trim(rsOrderTypes("OrderTypeString"))
%>
<option value="<%=iOrderTypeID%>|<%=sOrderTypeString%>"<%=IfSelected(sOrderTypeString, sOrderTypeString_NewRequest)%>><%=sOrderTypeString%></option>
<%
rsOrderTypes.MoveNext
Loop
%>
</select>
<%
rsOrderTypes.Close
Set rsOrderTypes = Nothing
End If
%>
'''
The SQL code generates the following code (as viewed in browser source):
'''
</select>
这是复选框 HTML:
<input type="checkbox" name="chkSkipVenueEventDetails" id="chkSkipVenueEventDetails"> <strong>Skip Venue & Event Details</strong>
牧羊人nacy
相关分类