Combo box on ASP page

  • Thread starter paulmitchell507
  • Start date
P

paulmitchell507

I am not sure if this should be posted in a Java forum, bit it does
concern asp.
I have the following script on my asp (classic) page.

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

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

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

//-->
</script>
</head>
<body>
<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 ("staff_ID") & "'
SELECTED>"
Response.Write oRs("firstlastName") & "</Option>"
oRs.MoveNext
else
Response.Write "<OPTION VALUE = '" & oRs ("Staff_ID") & "'>"
Response.Write oRs("firstlastName") & "</Option>"
oRs.MoveNext
end if
loop
The script works fine, it lists the firstlastname field from the
access 2k database and places the corrasponding staff_ID value in
Request.Form("courses"). What I would like to do is display the
selected firstlastname value in box further down the page.
I would appreciate it if anybody could help with, what looks like, a
simple task.
 
A

Anthony Jones

paulmitchell507 said:
I am not sure if this should be posted in a Java forum, bit it does
concern asp.
I have the following script on my asp (classic) page.

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

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

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

//-->
</script>
</head>
<body>
<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 ("staff_ID") & "'
SELECTED>"
Response.Write oRs("firstlastName") & "</Option>"
oRs.MoveNext
else
Response.Write "<OPTION VALUE = '" & oRs ("Staff_ID") & "'>"
Response.Write oRs("firstlastName") & "</Option>"
oRs.MoveNext
end if
loop
The script works fine, it lists the firstlastname field from the
access 2k database and places the corrasponding staff_ID value in
Request.Form("courses"). What I would like to do is display the
selected firstlastname value in box further down the page.
I would appreciate it if anybody could help with, what looks like, a
simple task.

Before being able t answer that we need to know why on selected an entry in
the combo you submit the form?
 
P

paulmitchell507

Before being able t answer that we need to know why on selected an entry in
the combo you submit the form?

I am not sure I fully understand the question (I am what you call a
newbie). Please find attched the rest of the code on my asp page.

</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>group_id :</td>
<td><input type="text" name="Name" value=""></td>
</tr>
<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>If requesting a half day, will you be absent A.M. or P.M.?</td>
<td>NA<input type="radio" name="ampm" value=""/>
AM<input type="radio" name="ampm" value="AM"/>PM<input type="radio"
name="ampm" value="PM"></td>
</tr>
<tr>
<td>Number of Working days :</td>
<td><input type="number" name="Numberofdays"></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>
<!-- 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

Similar Threads

Java script on classic ASP page 6
ASP/Java 3
classi asp 0
ASP/VBScript connected drop down box error 3
combo box 0
How can I type in the combo box <select> ? 8
looping question 4
Default value for combo box 11

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top