Java script on classic ASP page

P

paulmitchell507

I have the following Java script on a asp page located on my company
intranet.

<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

Could somebody tell me if it's possible to display the selected
"firstlastname" on the page? At the moment after the user makes a
selection the page is refreshed and the default 'firstlastname' is
displayed. The staff_ID value is stored in request.form("courses")
which is then posted to another ASP page but the user has no way of
telling which 'firstlastname' they selected.

My initial thoughts were to run a SQL statement using the staff_iD
held in request.form("courses") to retrieve and display the
'firstlastname'. But I don't think that will work.

Any help would be appreciated.
Classic ASP, Access 2K DB
 
A

Anthony Jones

paulmitchell507 said:
I have the following Java script on a asp page located on my company
intranet.

<html>
<head>
<title>Example combo box</title>
<script language="javascript">
<!--
function dept_onchange(frmSelect) {
frmSelect.submit();
}


In the other thread with an identical question I asked you why you were
doing the above??

If you can answer that we can move forward. BTW, starting another thread is
a little annoying.
 
P

paulmitchell507

In the other thread with an identical question I asked you why you were
doing the above??

If you can answer that we can move forward.  BTW, starting another thread is
a little annoying.

I assumed that as I had not replied to your post for such a long time
that the original thread was dead, I do apologise.
I am attempting to create a internal holiday request application. I
am using the javascript to provide a drop down list, the user can then
select his/her name from the list.

The corresponding staff_ID is then passed to the next asp page for
entry into the database. I just want the user to be able to see on
screen that they have selected the correct entry from the list. At
the moment, the screen is refreshed after the selection has been made.
 
A

Anthony Jones

In the other thread with an identical question I asked you why you were
doing the above??

Paul,

When you ask for help you will most likely get responses that ask you
questions so that what you are doing is better understood and the help can
be more targeted. Its very frustating trying to help someone when they
won't answer the questions posed to them. I'd like to help further but
unless I know the answer to the above question I'm afraid I can't.
 
P

paulmitchell507

Paul,

When you ask for help you will most likely get responses that ask you
questions so that what you are doing is better understood and the help can
be more targeted.  Its very frustating trying to help someone when they
won't answer the questions posed to them.  I'd like to help further but
unless I know the answer to the above question I'm afraid I can't.

Sorry, we have not got off on a very good footing here!
<html>
<head>
<title>Example combo box</title>
<script language="javascript">
<!--
function dept_onchange(frmSelect) {
frmSelect.submit();
}

Why have I done the above? Because I was looking for an example of a
drop down box that would display the 'firstlastname' field but pass
the staff_ID field. This was the first example I found that appeared
to work. If you have an alternative solution I would be more than
happy to change the code above.
 
B

Bob Barrows [MVP]

paulmitchell507 said:
Sorry, we have not got off on a very good footing here!


Why have I done the above? Because I was looking for an example of a
drop down box that would display the 'firstlastname' field but pass
the staff_ID field. This was the first example I found that appeared
to work. If you have an alternative solution I would be more than
happy to change the code above.

You're still missing the point. Anthony is asking about this specific
function:


Why are you wanting to submit the form when the listbox selection
changes?
It appears the answer is that you have copy/pasted this html from
somewhere and you do not know why the code was written to cause the form
to be submitted when the selection changed. is that correct?
 
P

paulmitchell507

You're still missing the point. Anthony is asking about this specific
function:


Why are you wanting to submit the form when the listbox selection
changes?
It appears the answer is that you have copy/pasted this html from
somewhere and you do not know why the code was written to cause the form
to be submitted when the selection changed. is that correct?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.- Hide quoted text -

- Show quoted text -

You are correct to say that I do not know why the code was written to
cause the form to be submitted when the selection changed. Is it
possible that the page needs to be submitted each time a selection is
changed so the corrasponding staff_ID is placed in
request.form("courses")? If I was to select user A form the listbox I
need user A's staff_ID recorded. If I changed my mind and selected
user B, I would need user B's staff_ID recorded.

Paul
 

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,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top