0

我已经在网上搜索了几个小时,但我仍然无法理解这个!

首先,我有这个代码,这是我创建的表单。

<!-- #include file="Header.asp" -->
<!-- #include file="Tauthenticate.asp" -->
<!--#include file="database.asp"-->

<SCRIPT LANGUAGE="JavaScript">

function confirmSubmit()
{
var agree=confirm("Confirm?");
if (agree)
return true ;
else
return false ;
}
</script>


    <table border="0" width="100%" cellspacing="0" cellpadding="0" id="table17">
        <tr>
            <td background="../images/bar1.jpg"><font size="2">&nbsp;<b>Add 
            Skill</b></font></td>
        </tr>
        </table>
            <table border="0" width="100%" id="table18" cellspacing="0" cellpadding="0">
                <form method="POST" action="SaveNewSkill.asp">
                <tr>

                </tr>

                <td width="108"><font face="Verdana" size="2" >Employee </font> </td>
    <td>


        <p><font face="Verdana"><select size="1" name="D1">
        <%
            sql="select User_ID, First_Name, Surname from Company Where Status not like 'left%' and (Company.Office='Manchester' or Company.Office='Romania') order by Surname"
            set users=conn.execute(sql)
            do while not users.eof 
                %>
                    <option value="<%=users("User_ID")%>"><%=users("First_Name") & " " & users("Surname")%></option>
                <%
                users.movenext
                loop
                set users=nothing
                %>
        </select></font></p>

    </td>


                <tr>
                    <td width="142"><b><font size="2" face="Verdana">Skill</font></b></td><td>
                    <select size="1" name="D3">
                    <option value="AutoCad 2D">AutoCAD 2D</option>
                    <option value="3D Modeling">3D Modeling</option>
                    <option value="Sketchup">Sketchup</option>
                    </select></td>

                </tr>

                <tr>
                    <td width="142"><b><font size="2" face="Verdana">Current Skill Level</font></b></td><td>
                    <select size="1" name="D4">
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
                    <option value="5">5</option>
                    </select></td>

                </tr>

                    <tr>
                    <td width="142"><b><font size="2" face="Verdana">Required Skill Level</font></b></td><td>
                    <select size="1" name="D4">
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
                    <option value="5">5</option>
                    </select></td>

                </tr>

                </form>
                </table>
    <form><p><font size="2"><input type="submit" value="Save" name="B1" onclick="return confirmSubmit()"></font></form>
    <td width="75">
            <!-- #include file="footer.asp" -->

包含的文件用于标题、与数据库的连接以及首先查看页面的身份验证(所有这些都有效)。

该表单在数据库中查询我们的用户列表,然后允许用户从列表中选择一项技能并定义他们当前的专业水平。

然后我创建了这个“保存技能”asp页面。

<!--#include file="database.asp"-->
<!--#include File="TUauthenticate.asp"-->


<%


User_ID=request.querystring("User_ID")
sql="select * from company where User_ID=" & User_ID
set rs=conn.execute(sql)
Session("User_ID")=User_ID


Skill=request.form("D3")
Current_Level=Request.form("D4")
User_ID=request.form("D1")
Required_Level=request.form("D5")

if request.form("B1")<>"" then
if skill = "AutoCAD 2D" then
sqlq="insert into skills (User_ID, AutoCad_2D, AutoCad_2DR) Values (" & User_ID & ",'" &    Current_Level & "','" & Required_Level & "')"
response.write(sqlq)
set rs=conn.execute(sqlq)
end if
end if

%>

我已经使用各种工作代码将它放在一起,但它不会保存到数据库中......我理解它不是很整洁,但一旦我知道它有什么问题,我会对其进行排序。

我知道我已经包含了一些 javascript 但如果答案是在 asp 代码中我会优先考虑(因为我目前正在尝试研究 asp)

提前谢谢各位!:D

4

2 回答 2

1

查看您的代码,如果满足以下条件,您将只看到您的 response.write(sqlq) 的响应:

1) 如果 B1 = 无

2) 他们从选择框中选择 AutoCAD 2D。

所以那里有两个潜在的问题。

我建议删除if request.form("B1")<>"" then要求并重试,确保选择 AutoCAD 2D 选项。

于 2012-11-01T16:20:27.980 回答
0
<%


sdate =request.form("T1")
stime =request.form("T2")
datetime=sdate & " " & stime

iUserID=request.form("D2")
iSkillLevel=request.form("D4")
iRSkillLevel=request.form("D5")
hdid=Session("hdid")
wuser=Request.ServerVariables("Logon_User")

uploadid=request.form("D56")
filepath=request.form("B23")
hyperlink=request.form("T6")


If Request.Form("B11") <> "" then
sqlq = "INSERT INTO Skills (User_ID, AutoCad_2D, AutoCad_2DR) VALUES ('" & iUserID & "','" & iSkillLevel & "','" & iRSkillLevel & "')"
response.write(sqlq)
set rs=conn.execute(sqlq)
end if

set rs=nothing
If Request.Form("B11") <> "" Then Response.Redirect(Session("lastpage"))

%>
于 2012-11-05T11:27:21.453 回答