troubleshooting Question

Need to pass variable in Javascript to my ASP pgm

Avatar of OGSan
OGSanFlag for United States of America asked on
ASP
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;
	    document.getElementById
        ('selectedResult').innerHTML = "Empl ID = "+strSelectedID;
	    }
    </script>
.
.
.
'-- 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)
%>
 <form>
 <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>
<%               
    rsSelect.moveNext()				
 Wend
 
If (rsSelect.CursorType > 0) Then
  rsSelect.MoveFirst
Else
  rsSelect.Requery
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.
%>
 </select>
 </form>
<%
'       Close connection, deinitialize from memory
 
        rsSelect.close
        set rsSelect = nothing
  
        objSickOnlineConn.Close
        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>") 
%>
ASKER CERTIFIED SOLUTION
Wayne Barron
Author, Web Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2009

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros