0

I have been googling the net for hours and i still can't get my head around this!

to start with, i have this code which is the form i have created.

<!-- #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" -->

the files that are included are for the header, connection to the database and authentication to view the page in the first place (which all works).

the form queries the database for our list of users then allows the user to select a skill from a list and define their current level of expertise.

i have then created this "save skill" asp page.

<!--#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

%>

i have put this together using various pieces of working code but it will not save to the database... i understand its not very neat but i will sort that once i know whats wrong with it.

i know i've included a little bit of javascript but i'd prefare if answers were in asp code (as im currently trying to study asp)

Thanks in advance guys! :D

6
  • what is the result of this. An error or a null value Commented Nov 1, 2012 at 12:05
  • What does your response.write(sqlq) write out to the web page? Commented Nov 1, 2012 at 12:11
  • it doesnt actually do anything haha, just resets all the values in the form as if its redirected back there but nothings actually been added to the database... Commented Nov 1, 2012 at 12:51
  • you should begin the <form> tag before the form fields and close it after the submit button. and also specify the action= part and method="post" Commented Nov 2, 2012 at 6:36
  • ie: remove the extra </form> and <form> you have here: </form> </table> <form> Commented Nov 2, 2012 at 10:59

2 Answers 2

1

Looking at your code, you will only see the response of your response.write(sqlq) if the following conditions are met:

1) If B1 = nothing

2) They choose AutoCAD 2D from the select box.

So there are two potential issues there.

I'd suggest removing the if request.form("B1")<>"" then requirement and trying again, ensuring you select the AutoCAD 2D option.

Sign up to request clarification or add additional context in comments.

Comments

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"))

%>

1 Comment

Thanks for the help guys! i actually ended up re writing it, i think there was also a conflicting variables (User_ID). all of it works i just need to include multiple if statements so that the user can select different skills from the list :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.