Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Need to pass variable in Javascript to my ASP pgm

Avatar of OGSan
OGSanFlag for United States of America asked on
8 Comments1 Solution566 ViewsLast Modified:
Expert Carrzkiss helped me with a bit of ASP 3.0 code in order to get my pgm to display a dropdown box populated with employees that the User is authorized to enter payroll time for (see Q_24240327).  A Javascript routine was used to capture the Empl ID associated with the selected employee.  Problem now is I need to pass that value to my ASP pgm...hopefully without leaving the page.
Is this possible to do?  Below is the relevant code.
<!-- Save the Selected Empl ID from the dropdown -->
    <script type="text/javascript">
    var strSelectedID;
	function showSelected(val){
		strSelectedID = val;
        ('selectedResult').innerHTML = "Empl ID = "+strSelectedID;
'-- F I L L    D R O P D O W N   W I T H   E M P L O Y E E S  -->
     ' Open connection string to the Sick Time Entry Online database
     If not IsObject(objSickOnlineConn) then
            strDataPath = server.MapPath("/hr/db/public/AbsTimeEntryOnline.mdb;")
            set objSickOnlineConn = Server.CreateObject("ADODB.Connection")
            strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;"_
                  + " Data Source= " & strDataPath & ";"_
                  + " Mode=Share Deny None;"
            objSickOnlineConn.ConnectionTimeout = 15
            objSickOnlineConn.CommandTimeout =  10
            objSickOnlineConn.Mode = 3 'adModeReadWrite 
            if objSickOnlineConn.state = 0 then
               objSickOnlineConn.Open strConnectString
            end if
      end if
'***** T E S T I N G     O N L Y *****    TEST ONLY!
 strEmplID = "1000003"
sql = "SELECT DISTINCT [EmplID_(OPRDEFN)], [EE Name] AS EE_Name, [EmplID_(GROUP_DTL)] AS Selected_ID FROM tbl_EmplID_RowSecurity_xref WHERE (([EmplID_(OPRDEFN)])=" & strEmplID & ") Order by [EE Name];"
'***** D E B U G *****    
' Response.Write(sql & "<br>")
 set rsSelect = objSickOnlineConn.execute(sql)
 <select name="Name" style="font: 8pt verdana;" onChange='showSelected(this.value)'>
 <option value="">Select Employee</option>
 While (NOT rsSelect.EOF)
    <option value="<%=(rsSelect.Fields.Item("Selected_ID").Value)%>" <%if (CStr(rsSelect.Fields.Item("EE_Name").Value) = CStr(rsSelect.Fields.Item("EE_Name").Value)) then Response.Write("SELECTED") : Response.Write("EE_Name")%>><%=(rsSelect.Fields.Item("EE_Name").Value)%></option>
If (rsSelect.CursorType > 0) Then
End If
' added in to the bottom, and extra Blank Select, for those DEEP Select List, instead of scrolling to the top, the visitor can simply choose this to end the use of this area.
'       Close connection, deinitialize from memory
        set rsSelect = nothing
        set objSickOnlineConn = nothing
<!-- Employee ID is displayed below -->
<div id='selectedResult'></div>
<!-- But how do I get it back to ASP? -->
Response.Write("***** D E B U G&nbsp;&nbsp;&nbsp;S T A R T *****<br>")  
Response.Write("strSelectedID: " & strSelectedID & "<br>")
Response.Write("***** D E B U G&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;E N D   *****<br>") 
Avatar of Wayne Barron
Wayne BarronFlag of United States of America imageAuthor, Web Developer
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answers