Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic combo help...

Status
Not open for further replies.

mjonson

Technical User
Mar 9, 2004
128
GB
which part of the code below chooses the filter field to pass to a second combo box please?

<%
x_stypeidList = "<select name='x_stypeid' onChange='EW_updatecombo(this.form.x_partnerid, ar_x_partnerid, this.options[this.selectedIndex].value);'><option value=''>Please Select</OPTION>"
sqlwrk = "SELECT `stype`,`partid`, `stocktype`, `snotes` FROM `tbl_stocktype`"
Set rswrk = Server.CreateObject("ADODB.Recordset")
rswrk.Open sqlwrk, conn, 1, 2
rswrk(stype) = stype
If Not rswrk.Eof Then
datawrk = rswrk.GetRows
rowswrk = UBound(datawrk, 2)
For rowcntwrk = 0 To rowswrk
x_stypeidList = x_stypeidList & "<option value='" & datawrk(0, rowcntwrk) & "'"
If CStr(datawrk(0, rowcntwrk)&"") = CStr(x_stypeid&"") Then
x_stypeidList = x_stypeidList & " selected"
End If
x_stypeidList = x_stypeidList & ">" & datawrk(1, rowcntwrk) & ", " & datawrk(2, rowcntwrk) & "</option>"
Next
End If
rswrk.Close
Set rswrk = Nothing
x_stypeidList = x_stypeidList & "</select>"
Response.Write x_stypeidList
%>
 
It's the:

onChange='EW_updatecombo(this.form.x_partnerid, ar_x_partnerid, this.options[this.selectedIndex].value);'>

That takes the value the person clicks on and runs the function 'EW_updatecombo' where ever that is in your code.
 
im stuck...
i want a dynamic combo that will select from this table

tbl_stocktype
stypeid stocktype partid
----------------------------
1 A 3
2 B 3
3 C 5
4 D 5
5 E 6

and populate the second from this table using partid from
tbl_stocktype and stype from tbl_partner

tbl_partner
partnersid partname stype
---------------------------
1 A 3
2 B 3
3 C 3
4 D 3
5 E 5

do i need to include the java or is the code below enough?
thanks for your help

combo1
Code:
<%
x_stypeidList = "<select name='x_stypeid' onChange='EW_updatecombo(this.form.x_partnerid, ar_x_partnerid, this.options[this.selectedIndex].value);'><option value=''>Please Select</OPTION>"
cbo_x_stypeid_js = "" ' Initialise
sqlwrk = "SELECT `stypeid`, `stocktype`, `snotes`, `partid` FROM `tbl_stocktype`"
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_stypeidList = x_stypeidList & "<option value='" & datawrk(0, rowcntwrk) & "'"
        If CStr(datawrk(0, rowcntwrk)&"") = CStr(x_stypeid&"") Then
            x_stypeidList = x_stypeidList & " selected"
        End If
        x_stypeidList = x_stypeidList & ">" & datawrk(1, rowcntwrk) & ", " & datawrk(2, rowcntwrk) & "</option>"
cbo_x_stypeid_js = cbo_x_stypeid_js & "ar_x_stypeid[" & rowcntwrk*4 & "] = '" & Replace(datawrk(0, rowcntwrk)&"","'","\'") & "';" ' Value
cbo_x_stypeid_js = cbo_x_stypeid_js & "ar_x_stypeid[" & rowcntwrk*4+1 & "] = '" & Replace(datawrk(1, rowcntwrk)&"","'","\'") & "';" ' Display field 1
cbo_x_stypeid_js = cbo_x_stypeid_js & "ar_x_stypeid[" & rowcntwrk*4+2 & "] = '" & Replace(datawrk(2, rowcntwrk)&"","'","\'") & "';" ' Display field 2
cbo_x_stypeid_js = cbo_x_stypeid_js & "ar_x_stypeid[" & rowcntwrk*4+3 & "] = '" & Replace(datawrk(3, rowcntwrk)&"","'","\'") & "';" ' Filter field
    Next
End If
rswrk.Close
Set rswrk = Nothing
x_stypeidList = x_stypeidList & "</select>"
Response.Write x_stypeidList
%>
<script language="JavaScript">
<!--
var ar_x_stypeid = new Array();
<%= cbo_x_stypeid_js %>
//--></script>

combo2
Code:
<%
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
    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>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top