ASP/Java

  • Thread starter paulmitchell507
  • Start date
P

paulmitchell507

I am not sure if this should be posted in a Java newsgroup or not, I
am sure I will be told where it should be! I have a small
asp(classic) app that runs the following java script to display a drop
down list containing usernames from a access 2k database.

<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

This works, to the point where it puts the value of staff_ID into
request.form("courses"). What I would like to do is store the
"Group_ID" values also. Please could somebody provide the code to
store the additional value. I then post the 2 values to a another asp
page for insertion into another table in the database.

Regards.
 
T

Tim Slattery

paulmitchell507 said:
I am not sure if this should be posted in a Java newsgroup or not, I
am sure I will be told where it should be! I have a small
asp(classic) app that runs the following java script to display a drop
down list containing usernames from a access 2k database.

<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

This works, to the point where it puts the value of staff_ID into
request.form("courses"). What I would like to do is store the
"Group_ID" values also. Please could somebody provide the code to
store the additional value. I then post the 2 values to a another asp
page for insertion into another table in the database.

Where to start? You're not using Java, you're using JavaScript, the
two are completely different. And your question has nothing to do with
that either.

When you select an item from a listbox or dropdown box (both of which
are <select...> groups and submit the form, the "value" string in the
<option..> tag is sent to the browser. That's it ONE value.

You can create that value string so that it has several parts divided
by (for example) a semicolon. So your option tag might look something
like this:

<option value="staffid;groupid">something</option>

Now when the form is submitted, you get that value ("courses", in your
case), and parse it on the semicolon (see the VBScript "split"
function
[http://msdn.microsoft.com/en-us/library/0764e5w5(VS.85).aspx]). Now
you have your two values.
 
A

Anthony Jones

paulmitchell507 said:
I am not sure if this should be posted in a Java newsgroup or not, I
am sure I will be told where it should be! I have a small
asp(classic) app that runs the following java script to display a drop
down list containing usernames from a access 2k database.

<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

This works, to the point where it puts the value of staff_ID into
request.form("courses"). What I would like to do is store the
"Group_ID" values also. Please could somebody provide the code to
store the additional value. I then post the 2 values to a another asp
page for insertion into another table in the database.

Where is the Group_ID?

Can't the second ASP page determine the Group_ID by query the DB with the
Staff_ID it has?
 
P

paulmitchell507

Where is the Group_ID?

Can't the second ASP page determine the Group_ID by query the DB with the
Staff_ID it has?

Thank you very much for you input, as you can tell, I am newbie!
In the end I used the second ASP page to determine the Group_ID using
the Staff_ID.
 

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

Forum statistics

Threads
473,968
Messages
2,570,149
Members
46,695
Latest member
StanleyDri

Latest Threads

Top