I need to pass the selected value from dropdownlist to the SELECT query and based on the value passed the respective table/recordset displayed in the page. I'm struggling to find way to how to pass the value.
function getUnitCode() {
var x = document.getElementById("UnitCodeDDL");
var unical = x.options[x.selectedIndex].value;
alert(unical);
}
<%
Dim strUnitCode
strUnitCode=Request.Form("UnitCodeDDL")
%>
<SELECT NAME=UnitCodeDDL id=UnitCodeDDL onchange="getUnitCode();javascript: document.forms['VehForm'].submit()">
<OPTION VALUE=''>Please Select UnitCode</OPTION>
<%
Dim objRS , strSQL
Set objRS=Server.CreateObject ("ADODB.Recordset")
strSQL = "SELECT v.unitcode, u.description "
strSQL = strSQL & "FROM " & strBrand & "_vehicle AS v "
strSQL = strSQL & "LEFT JOIN unipos AS u "
strSQL = strSQL & "ON v.unitcode = u.unitcode "
strSQL = strSQL & "WHERE v_code='" & strVCode & "' "
strSQL = strSQL & "GROUP BY v.unitcode;"
objRS.Open strSQL,objConn
Do While Not objRS.EOF
Response.Write "<OPTION VALUE='" & objRS("unitcode") & "'"
if objRS("unitcode")=strUnitCode Then Response.Write " selected "
Response.Write ">"
Response.Write objRS("unitcode") & "</OPTION>"
objRS.MoveNext
Loop
objRS.Close
Set objRS=Nothing
Response.Write "</SELECT>"
%>
<%
Dim strAutoSection
strAutoSection = strAutoSection & "<FORM name='VehForm' METHOD=POST ACTION='selectVeh.asp?brand=" & strBrand & "&VCode=" & strVCode & "&Veh=" & server.htmlencode(strVeh) & "&action=upload' enctype='multipart/form-data'>" & vbCrLf
strAutoSection = strAutoSection & "Upload file:<INPUT TYPE='file' NAME='uploadFile'><input type='submit' value='upload'></FORM>"
strAutoSection = strAutoSection & "<TABLE border=1 cellspacing=1 cellpadding=2>" & vbCrLf
strAutoSection = strAutoSection & "<TR bgcolor='#CCFFCC'>" & vbCrLf
strAutoSection = strAutoSection & "<TH>UNITCODE</TH>" & vbCrLf
strAutoSection = strAutoSection & "<TH>DESCRIPTION</TH>" & vbCrLf
strAutoSection = strAutoSection & "</TR>" & vbCrLf
Dim objRS_auto,strSQL
Set objRS_auto=Server.CreateObject ("ADODB.Recordset")
strSQL = "SELECT v.*, u.description "
strSQL = strSQL & "FROM " & strBrand & "_vehicle AS v "
strSQL = strSQL & "LEFT JOIN unitpos AS u "
strSQL = strSQL & "ON v.unitcode = u.unitcode "
strSQL = strSQL & "WHERE v_code='" & strVCode & "' AND v.unitcode='" & strUnitCode & "' "
objRS_auto.Open strSQL, objConn
%>
All I have to get the value from UnitCodeDDL on onchange event and pass the same to strUnitCode variable in the query. Can anyone please guide me how to solve this?