Hi
I have a combo box on an asp form, which reads values from a sql database using a sub and a function in an include file as below
within the asp file i have this which allows the user to select either commercial or domestic and further below the code to build up the select for the pest types (using the sub above)
if the user selects, say Bee and Commercial I'd like to fire an onchange event for selPest and read the value from
varCost_Com from tblCompType (as specified in the sub) for example. if it was domestic then varCost_Dom
so an example row in tblCompType is
CompTypeID, varInidcator, varCompType, varCost_Dom, varCost_com
10, Pest, Bees, Do not treat, Do not treat
thanks
kim
I have a combo box on an asp form, which reads values from a sql database using a sub and a function in an include file as below
Code:
Sub getPestTypes(oRS)
On Error Resume Next
if Err.number=0 then
set oRS = ExecQueryRS_X("CONN_Z","SELECT compTypeID, varIndicator,varCompType, varCost_Dom, varCost_Com FROM tblCompType where varIndicator='Pest'",null)
if Err.Number <> 0 then
set oRS = Nothing
end if
else
end if
End Sub
Function getPestName(strID)
Dim oRS
set oRS = ExecQueryRS_X("CONN_Z","SELECT compTypeID, varIndicator,varCompType, varCost_Dom, varCost_Com FROM tblCompType WHERE compTypeID=?",Array(adnumeric,5,strID))
if Err.number=0 then
getPestName=oRS(0)
oRS.Close
else
getPestName=""
end if
set oRS = Nothing
End Function
within the asp file i have this which allows the user to select either commercial or domestic and further below the code to build up the select for the pest types (using the sub above)
if the user selects, say Bee and Commercial I'd like to fire an onchange event for selPest and read the value from
varCost_Com from tblCompType (as specified in the sub) for example. if it was domestic then varCost_Dom
so an example row in tblCompType is
CompTypeID, varInidcator, varCompType, varCost_Dom, varCost_com
10, Pest, Bees, Do not treat, Do not treat
thanks
kim
Code:
'Pest Types
'===========
set oRSPestTypes = Server.CreateObject("ADODB.Recordset")
getPestTypes oRSPestTypes
Response.Write " <tr>" & vbLf
'at the last minute, client requested that input box be labelled as 'Reason for Enquiry'
'hence, the below label; in the database though, the table corresponding to this is still called
'CTS_PEST TYPES'
'inconsistent I know, but what can you do about last minute changes!?
'so, if client uses Business Objects and asks which table to use for 'Reason for Enquiry', give above table name
Response.Write " <td align=right><span class=clsMainText>Pest Type:</span></td>" & vbLf
Response.Write "<td><select name=selPest onchange=""selPestChange();frmEnquiry.submit()"">" & vbLf
Response.Write " <option value=""-1"">" & vbLf
oRSPestTypes.MoveFirst
if Err.Number = 0 then
while not oRSPestTypes.EOF
Response.Write " <option " &
IIf(Request("selPest")&""=CStr(oRSPestTypes("compTypeID")),"SELECTED","") & " value=""" & oRSPestTypes("compTypeID") & """>"
& Server.HTMLEncode(oRSPestTypes("varCompType")) & vbLf
oRSPestTypes.MoveNext
wend
else
Response.Write "<option value=""-1"">CANNOT GET LIST OF PEST TYPES??"
end if
Response.Write "</select>"
Response.Write " <span class=clsMainText>Pest Cost:</span><font size=1><span class=clsTextColor></span></font>"
& vbLf
Response.Write " <input type=text readonly=true size=10 name=txtPestCost value=" &
Server.HTMLEncode(Request("txtPestCost")&"") & ">" & vbLf
response.write " </td>" & vbLf
oRSPestTypes.Close
set oRSPestTypes = nothing
Response.Write " </tr>" & vbLf
Code:
Response.Write "function selPestChange()" & vbLf
Response.Write "{" & vbLf
????????
Response.Write " }" & vbLf
Response.Write "}" & vbLf