Welcome to Dream.In.Code
Getting Help is Easy!

Join 109,551 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,259 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Dynamic Drop Down List populates Drop Down List issue

 
Reply to this topicStart new topic

Dynamic Drop Down List populates Drop Down List issue, Client-Side and Server-Side not playing well together

mamadon
post 25 Jul, 2008 - 11:44 AM
Post #1


New D.I.C Head

*
Joined: 25 Jul, 2008
Posts: 1

In the code I have 2 ddlists. The first ddl is populated by SQL db tables the second also has a value from the db and it's remaining options are generated by the javascript. Is there a way to get the "SubStatus" recordset return in the drop down list to display? Only the Javascript ddlist shows but not the recordset return (line 62 in code) I realize this is a client and server side issue, but I don't know what to do to get rs("SubStatus") to display. Here's the code...
CODE
<%
'rs recordset returns the Status and Substatus from sql db
'PREPOP Sub
sqlstring = "select * from subs"
set rs1 = objConn.execute(sqlstring)
x=0 %>
<script language = "JavaScript">
function sublist(inform, selecteditem)
{
    inform.SubStatus.length = 0
    var dbsubstatus = "<%= rs("SubStatus") %>"
    var dbstatus = "<%= rs("Status") %>"
    
    <%
    count= 0
    y=0
    do while not rs1.eof
    %>
    x = <%= trim(y) %>
    subcat = new Array();
    subcatagorys = "<%= trim(rs1("SubStatus"))%>"
    subcatagoryof = "<%= trim(rs1("StatusCode"))%>"
    subcat[x,0] = subcatagorys;
    subcat[x,1] = subcatagoryof;
    
    if (subcat[x,1] == selecteditem)
    {
        var option = new Option(subcat[x,0], subcat[x,2]);
        inform.SubStatus.options[inform.SubStatus.length]=option;
    }
    <%
    count = count + 1
    y = y + 1
    rs1.movenext
    loop
    %>
}
</script>
<BODY onLoad = "sublist(document.reqform,document.reqform.status[document.reqform.status.selectedIndex].value)">
<form action="RequestUpdate.asp" method="post" name="reqform">
<%
cat = Request.QueryString("cat")
sqlstring2 = "SELECT Distinct StatusCode from subs"
set rs2 = objConn.execute (sqlstring2)
%>
<p>Status:
<SELECT id=status name=status onChange="java script:sublist(this.form, document.reqform.status[document.reqform.status.selectedIndex].value)">
<option value="<%= rs("Status") %>"><%= rs("Status") %></option>
<%
do until rs2.eof
%>
<OPTION value="<%= rs2("StatusCode")%>"><% = rs2("StatusCode")%></OPTION>
<%
rs2.movenext
loop
set rs2 = nothing
%>
</SELECT>
</p>    
<p>Sub Status
<SELECT id =SubStatus name=SubStatus>
<Option selected value="<%= rs("SubStatus") %>"><%= rs("SubStatus") %></option>
</SELECT>
</p>
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/7/08 10:37PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month