classi asp

P

paulmitchell507

As my post will demonstrate, I am just picking up ASP as I go. I
have
written the small ASP app below. For some reason I can't get my head
around how I can pass the staff_ID value to add_to_database.asp. I
donlt want to display the value but I want to input the value into my
holiday_tbl.

<%@ Language=VBScript %>
<%Option explicit
Dim oRs, conn, connect, strSQL, inpSQL


set conn=server.CreateObject ("adodb.connection")
connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("staff.mdb") & ";Persist Security Info=False"
conn.Open connect


%>
<html>
<head>
<title>Example combo box</title>


<script language="javascript">
<!--


function dept_onchange(frmSelect) {
frmSelect.submit();



}


//-->
</script>
</head>
<body>
The following was selected : <%=Request.Form("courses")%>

<form name="frmSelect" method="Post" action="select.asp">
<SELECT name=courses LANGUAGE=javascript onchange="return
dept_onchange(frmSelect)">
<%
Set oRs=Server.CreateObject("adodb.recordset")
strSQL = "SELECT Status_ID, Staff_ID, firstlastName FROM staff
WHERE
Status_ID=1 Or Status_ID=19 ORDER by firstlastname"
oRs.Open strSQL, conn


Do while not oRs.EOF
if Request.Form("courses") = oRs("firstlastName") then
'if this is
the selected one then display as selected
Response.Write "<OPTION VALUE = '" & oRS
("firstlastName") & "'
SELECTED>"
Response.Write oRs("firstlastName") & "</
Option>"
oRs.MoveNext
else
Response.Write "<OPTION VALUE = '" & oRs
("firstlastName") & "'>"
Response.Write oRs("firstlastName") & "</
Option>"
oRs.MoveNext
end if
loop
%>


</SELECT>
</form>
<html>
<head>
<title>Form to Database</title>
</head>
<body>
<!-- comment - start the HTML form and use a HTML table for
formatting-->
<form name="form1" action="add_to_database.asp" method="post">
<div align="center">
<table width="80%" border="0">
<tr>
<td>StartDate :</td>
<td><input type="text" name="StartDate"></td>
</tr>
<tr>
<td>EndDate :</td>
<td><input type="text" name="EndDate"></td>
</tr>
<tr>
<td><input type="HIDDEN" name="courses" value="<
%=Request.Form("courses")%>"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" value="submit details" name="submit"></td>
</tr>
</table>
</div>
</form>
The following was selected : <%=Request.Form("courses")%>
<!-- end the HTML form-->
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top