Combo box on ASP page

This is a discussion on Combo box on ASP page within the Inetserver forums in Microsoft Tools category; 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 = '" & ...

Go Back   Application Development Forum > Microsoft Tools > Inetserver

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-08-2008, 03:15 AM
paulmitchell507
Guest
 
Default Combo box on ASP page

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.
Reply With Quote
  #2  
Old 08-08-2008, 05:23 AM
Anthony Jones
Guest
 
Default Re: Combo box on ASP page

"paulmitchell507" <paulmitchell507@googlemail.com> wrote in message
news:dfb4f1cf-382a-4362-bd71-95364994694e@z66g2000hsc.googlegroups.com...
> 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?


--
Anthony Jones - MVP ASP/ASP.NET


Reply With Quote
  #3  
Old 08-08-2008, 10:22 AM
paulmitchell507
Guest
 
Default Re: Combo box on ASP page

On Aug 8, 10:23*am, "Anthony Jones" <A...@yadayadayada.com> wrote:
> "paulmitchell507" <paulmitchell...@googlemail.com> wrote in message
>
> news:dfb4f1cf-382a-4362-bd71-95364994694e@z66g2000hsc.googlegroups.com...
>
>
>
>
>
> > 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?
>
> --
> Anthony Jones - MVP ASP/ASP.NET- Hide quoted text -
>
> - Show quoted text -


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>
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 04:41 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.