如何在没有单选按钮的情况下添加注释文本字段

时间:2018-05-08 15:08:50

标签: javascript asp-classic

我有两个表,一个是Menu表,如下所示: 菜单表

Menu_id Menu_name Menu_comment
------------------------------
1       Menu1     For classroom
2       Menu2     For students
3       Menu3     For Teacher

分类表

Category_id Category_name Menu_id
---------------------------------
1           CAt1          1
2           Cat2          1
3           cat1          2
4           cat2          2

我正在尝试创建一个表单来显示两个表中的这些值(如附图所示)。我显示菜单1,然后显示属于该特定菜单ID的此菜单下方的类别。然后是Menu2,然后是类别,菜单3等。

我的问题是,如何在没有单选按钮的情况下为每个菜单添加Menu_comment字段(如附图所示)?

enter image description here

这是我的代码:

<html>
<head>
<style>



* {font-family:arial;text-align:center;margin-left:auto;margin-right:auto;}

h2 {margin-bottom:10px;}

td {text-transform:capitalize;}

.ass-title {

                margin-top:50px;

                font-weight:bold;

                font-size:20px;

}

</style>



<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Skills Assessment View</title>

<link rel="stylesheet" type="text/css" href="style/certification.css">

<script language="Javascript" src="js/main.js" type="text/javascript"></script>

<script language="javascript">





function validateForm(daForm) {



nCount = document.frmReport.txtCount.value;



    // check all rb radio buttons

    for (var i = 1; i < nCount; i++) {

        if (! getCheckedRadioValue(daForm["Report"+i])) {

            alert ("Please select a value for option " + i)

                                                return false

                                }

                                if (document.querySelector("[name='UserID']").value == 0) {

                                                alert("Please select a staff");

                                                return false

                                }

    }


function getCheckedRadioValue(radio) {

    for (var i=0; i < radio.length; i++) {

        if (radio[i].checked) return radio[i].value

    }

    return false

}



</script>

<style>

table, td, th {

                border: 1px solid #ddd;

}

th, td {

                padding: 3px;

}

</style>

</head>

<body>



<%

If Request.Form("FormSource") = "SubmitForm" Then



                For j = 1 to Request.Form("txtCount")-1

                                strReport             = Request.Form("Report[" & j &"]")

                                strValue               = split(strReport, "$")

                                sMenuID                             = strValue(0)

                                sCategoryID       = strValue(1)

                                sStatus                 = strValue(2)

                                sUserID                                = Request.Form("UserID")

                                sEvaluatorID       = Request.Form("EvaluatorID")

                                sFormID                               = Request.Form("FormID")

                                sSubmitdate      = Request.Form( "dt")



                                sSQL =   "INSERT INTO Report (Form_id, Menu_id, Category_id, Status, User_id, Evaluator_id, Submitdate) VALUES " &_

                                                                "('" & sFormID & "', '" & sMenuID & "', '" & sCategoryID & "', '" & sStatus & "', '" & sUserID & "', '" & sEvaluatorID & "', '" & sSubmitdate & "');"

                                                objConn.Execute(sSQl)

                Next

End If

%>



<form action="" method="post" id="newMenu" name="frmReport" onSubmit="return validateForm(this)">

<p>

<input type="hidden" value="<%=Now%>" name="dt">

<div class="ass-title">EVALUATION</b></div>

<table>

<thead bgcolor="#336666" style="color:#FFFFFF">

                <tr>

        <td>

        </td>           

                                <td>&nbsp; Pass &nbsp;</td>

                                <td>&nbsp; Failed &nbsp;</td>

                                <td>&nbsp; NA &nbsp;</td>

                </tr>

</thead>



<%

currMenu = ""

'sSQL = "              SELECT Menu_id, Menu_Name FROM Menu WHERE Menu_id IN (SELECT Menu_id FROM Categories WHERE Form_id = " & nFormID & ")"

sSQL =   "              SELECT Menu_id, Menu_Name FROM Menu WHERE Menu_id IN (SELECT Menu_id FROM Categories WHERE Form_id = 25)"

                objRS.Open sSQL, objConn

                'response.Write sSQL

                i=1

                While Not objRS.EOF

                                nMenuID                             = objRS("Menu_id")

                                sMenuName     = objRS("Menu_Name")

                                If currMenu <> sMenuName Then

                                                currMenu = sMenuName

                                                %>

                                                <tr>

                <th bgcolor="#CCCCCC"><%= sMenuName %></th>

            </tr>

                <input type="hidden" name="MenuID" value="<%=nMenuID%>">

                                <%

                                End If

                                'sSQL3 = "SELECT Category_id, Category_Name FROM Categories WHERE Menu_id = " & nMenuID & " and Form_id = " & nFormID

                                sSQL3 = "SELECT Category_id, Category_Name FROM Categories WHERE Menu_id = " & nMenuID & " and Form_id = 25"

                                                Set objRS3 = Server.CreateObject("ADODB.Recordset")

                                                objRS3.Open sSQL3, objConn

                                                While Not objRS3.EOF

                                                                nCategoryID       = objRS3("Category_id")

                                                                sCategoryName               = objRS3("Category_Name")

                                %>

                                                <tr>

                <td><%= sCategoryName %></td>

                <input type="hidden" name="CategoryID" value="<%=nCategoryID%>">

                <td align="center"><input type="radio" id="Report<%=i%>" name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$2"></td>

                <td align="center"><input type="radio" id="Report<%=i%>" name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$1"></td>

                <td align="center"><input type="radio" id="Report<%=i%>" name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$0"></td>      

            </tr>

                                                <%

                                                objRS3.MoveNext

                                                i = i + 1

                                                Wend

                                                objRS3.Close

                                objRS.MoveNext

                Wend

                objRS.Close
%>

</p>
                <tr align="center">
                <td colspan="5">
<input type="hidden" name="txtCount" value="<%= i %>">
<input type="hidden" name="FormID2" value="<%= nFormID %>">
<input type="hidden" name="FormSource" value="SubmitForm">
<input type="submit" value="Submit Assessment">
<input type="button" value="Refresh" onclick="window.location.reload()"/>
</td></tr></table>
</form>


</div>
<%
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
%>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

您只想知道如何在HTML中添加文字?一个简单的解决方案,让你开始......:

<hr /><br /><p style="text-align:center;">For Student</p>