Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

retrieve the values from a text box on the same form 1

Status
Not open for further replies.

axslearnr

Technical User
Apr 1, 2004
78
US
Hi
I need some help.I will be very thankful to you if you can help me. This is my program stepwise. I had some guys helping me but I didnt get reply from them again thats why i am posting again. I appreciate them. Pls someone help me.

Note: Everytime I select an item from the combo box or select box I havea wrote function so it retuns the whole ReportTrainingType ASP page. with this function SubmitMe()

1) I have a combo box on a form which has three values. TP,SP,IP. When I select one of the value from the combobox TP, or IP or SP

2) it gives me a list of records which I populate in the Select box I have.

3) When I click on the select box item it gives me the records of the employee in that particular item. It gives me all the records.

4) I want only a certain number of records using the date fields.

5) So I kept a date field on the form and retrieve those values.

I used this function to refresh the ReportTrainingType ASP page
function SubmitMe()
{

document.TCForm.submit();
return(true);
}

' This is the initial combo box
<form method="POST" name="TCForm" action="RptTrainingbyTypeCode.asp?menuid=<%=menuid%>&typeid=<%=TType%>">
<SELECT name="TrainType" size="1" onchange="SubmitMe()">
<%
'Populate the drop down menu with training code names


response.write "<OPTION VALUE = -1> </OPTION>"
Do While NOT RST.EOF
if cint(RST("Training_Method_ID")) = TType then
Response.Write "<OPTION VALUE='" & RST("Training_Method_ID") & "' SELECTED>"
Response.Write RST("Training_Method_Text") & "</OPTION>"

else
Response.Write "<OPTION VALUE='" & RST("Training_Method_ID") & "'>"
Response.Write RST("Training_Method_Text") & "</OPTION>"

end if
RST.MoveNext
Loop

rst.close
set rst = nothing
%>

' This is the Select box where i select the item to display all the emp records.

response.write "<SELECT name='TrainCode' size='10' onclick='SubmitMe()'>"

'Go through list and write information
do while not rst.eof

WriteClass(TType)
rst.movenext
loop
response.write "</Select>"
end if
rst.close
set rst = nothing

' This where I display the all the emp records.

Set RST=Server.CreateObject("adodb.recordset")
rst.open strSQL, conn

if not rst.eof then
rst.MoveFirst



response.write "<tr><td><b><u>Employee Name</u></b></td><td align='center'><b><u>Date Trained</u></b></td><td><b><u>Employee Name</u></b></td><td align='center'><b><u>Date Trained</u></b></td></tr>"

CurrentName = -1
NameCount = 1
'Go through list and write information. Eliminate duplicates.
do while not rst.eof
if CurrentName <> rst("Employee ID") then 'Different Names. Print
if NameCount = 1 then
response.write "<tr>"
end if

Response.Write " <td width='200'>" & rst("First Name") & " " & rst("Middle Name") & " " & rst("Last Name") & "</td><td width='200' align='center'>" & rst("Training_Date") & "</td> "

if NameCount = 2 then
response.write "</tr>"
NameCount = 1
Else
NameCount = NameCount + 1
end if

CurrentName = rst("Employee ID")
' else Names are same. Do not print duplicates.
end if

rst.movenext 'Go to next record
loop



end if
rst.close
set rst = nothing
conn.close
set conn = nothing

end if
%>


Pls help me

Thanks
 
I would suggest using a dynamically created javascript function that will populate the combo boxes without round trips back to the server
 
Hi
Thanks for the reply. Can you suggest me how to do that javascript function. I dont know much abt javascript. Pls let me know.

thank you
 
To use the sample, create a table with 3 fields (cola, colb, colc) named ben.

<%
Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.Mappath("yourdb.mdb")

%>
<html>
<head>
<script language="JavaScript"><!--
var whatForm, whatTo, whatText;

function reshow(number) {
whatFrom = document.forms['formName'].elements['selectName' + number];
number++;
whatTo = document.forms['formName'].elements['selectName' + number];

for (var i = whatTo.length;i > 0;i--)
whatTo.options[0] = null;

whatText = whatFrom.options[whatFrom.selectedIndex].text;

showLink(number);

whatTo.options[0].selected = true;

if (number == 2)
reshow(2);

return false;
}

function showLink(number) {
if (number == 2)
showLink2()
else if (number == 3)
showLink3();
}

<%
Response.Write("function showLink2() {")&vbnewline



SQL8 = "Select distinct cola from ben order by cola"

Set RS8 = MyConn.Execute(SQL8)

While Not RS8.EOF
cola=RS8("cola")
Response.Write(" if (whatText == '"&cola&"') {")&vbnewline

SQL2 = "SELECT distinct colb FROM ben WHERE cola = '"&cola&"' ORDER BY colb"
Set RS2 = MyConn.Execute(SQL2)

While Not RS2.EOF
Response.Write(" opt('"&RS2("colb")&"','"&RS2("colb")&"');")&vbnewline
RS2.MoveNext
Wend
Response.Write(" }")&vbnewline

RS8.MoveNext
Wend
Response.Write("}")&vbnewline


Response.Write("function showLink3() {")&vbnewline



SQL18 = "Select distinct colb from ben order by colb"

Set RS18 = MyConn.Execute(SQL18)

While Not RS18.EOF
colb=RS18("colb")
Response.Write(" if (whatText == '"&colb&"') {")&vbnewline

SQL12 = "SELECT distinct colc FROM ben WHERE colb = '"&colb&"' ORDER BY colc"
Set RS12 = MyConn.Execute(SQL12)

While Not RS12.EOF
Response.Write(" opt('"&RS12("colc")&"','"&RS12("colc")&"');")&vbnewline
RS12.MoveNext
Wend
Response.Write(" }")&vbnewline

RS18.MoveNext
Wend
Response.Write("}")&vbnewline
%>
function opt(href,text) {
var optionName = new Option(text, href, false, false)
var length = whatTo.length;
whatTo.options[length] = optionName;
}
//--></script>
</head>

<body>
<center>

<form name="formName">
<select name="selectName1" onChange="reshow(1)">
<%
SQL99 = "Select cola,colb from ben order by cola,colb"

Set RS99 = MyConn.Execute(SQL99)
ZZ1=RS99("cola")
ZZ2=RS99("colb")

SQL = "Select distinct cola from ben order by cola"

Set RS = MyConn.Execute(SQL)
While Not RS.EOF
Response.Write ("<option value="""&RS("cola")&""">"&RS("cola"))
RS.MoveNext
Wend
Response.Write("</select></center><p><center><select name=""selectName2"" onChange=""reshow(2)"">")
SQL1 = "SELECT distinct colb FROM ben WHERE cola = '"&ZZ1&"' ORDER BY colb"

Set RS1 = MyConn.Execute(SQL1)

While Not RS1.EOF
Response.Write ("<option value="""&RS1("colb")&""">"&RS1("colb"))
RS1.MoveNext
Wend
Response.Write("</select></center><p><center><select name=""selectName3"">")
SQL11 = "SELECT distinct colc FROM ben WHERE colb = '"&ZZ2&"' ORDER BY colc"

Set RS11 = MyConn.Execute(SQL11)

While Not RS11.EOF
Response.Write ("<option value="""&RS11("colc")&""">"&RS11("colc"))
RS11.MoveNext
Wend
Response.Write("</select></center>")
%>
</center>
</body>
</html>
 
Hi
I really appreciate ur help. Thanks for the code. Can you modify my code given above according to the one given by u. That will really help. If you have time for it. I really appreciate ur help. pls let me know

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top