a dropdown is populated from a table but one of the fields is an id field for a lookup table.
i want a field from the lookup table to be displayed in the dropdown instead of the id.
ne advice welcome
my attempt
i want a field from the lookup table to be displayed in the dropdown instead of the id.
ne advice welcome
my attempt
Code:
<%
'codefor dropdown
x_partneridList = "<select name='x_partnerid'><option value=''>Please Select</OPTION>"
cbo_x_partnerid_js = "" ' Initialise
sqlwrk = "SELECT `partnersid`, `partmodid`, `partnotes`, `stype` FROM `tbl_partners`"
Set rswrk = Server.CreateObject("ADODB.Recordset")
rswrk.Open sqlwrk, conn, 1, 2
If Not rswrk.Eof Then
datawrk = rswrk.GetRows
rowswrk = UBound(datawrk, 2)
For rowcntwrk = 0 To rowswrk
x_partneridList = x_partneridList & "<option value='" & datawrk(0, rowcntwrk) & "'"
If CStr(datawrk(0, rowcntwrk)&"") = CStr(x_partnerid&"") Then
x_partneridList = x_partneridList & " selected"
End If
x_partneridList = x_partneridList & ">" & datawrk(1, rowcntwrk) & ", " & datawrk(2, rowcntwrk) & "</option>"
cbo_x_partnerid_js = cbo_x_partnerid_js & "ar_x_partnerid[" & rowcntwrk*4 & "] = '" & Replace(datawrk(0, rowcntwrk)&"","'","\'") & "';" ' Value
cbo_x_partnerid_js = cbo_x_partnerid_js & "ar_x_partnerid[" & rowcntwrk*4+1 & "] = '" & Replace(datawrk(1, rowcntwrk)&"","'","\'") & "';" ' Display field 1
cbo_x_partnerid_js = cbo_x_partnerid_js & "ar_x_partnerid[" & rowcntwrk*4+2 & "] = '" & Replace(datawrk(2, rowcntwrk)&"","'","\'") & "';" ' Display field 2
cbo_x_partnerid_js = cbo_x_partnerid_js & "ar_x_partnerid[" & rowcntwrk*4+3 & "] = '" & Replace(datawrk(3, rowcntwrk)&"","'","\'") & "';" ' Filter field
'my code for getting data from linked table
sqlcombomake = "SELECT modid, model FROM tbl_model WHERE modid = " & partmodid
Set rscombomake = Server.CreateObject("ADODB.Recordset")
rscombomake.open sqlcombomake, conn, 1, 2
Next
End If
rswrk.Close
Set rswrk = Nothing
x_partneridList = x_partneridList & "</select>"
Response.Write x_partneridList
%>
<script language="JavaScript">
<!--
var ar_x_partnerid = new Array();
<%= cbo_x_partnerid_js %>
//--></script>