Click to See Complete Forum and Search --> : Removing an option from the code in ASP and Javascsrpt


kalak
04-26-2007, 08:52 AM
:confused: I have arequirement to dynamically change 5 drop down on change of the 1st one. similiar for 2nd one change the rest of the drop downs in ASP
I would like to get some help for removing the options from list box in the following code when onchange event occurs.any help/suggestion is appreciated.
<html>
<head>
<SCRIPT language=JavaScript>




function readfdb(p_index,p_sub){




{
<%


set conn1=Server.CreateObject("ADODB.Connection")
set rs6 = Server.CreateObject("ADODB.recordset")
conn1.Provider="Microsoft.Jet.OLEDB.4.0"
conn1.Open(Server.Mappath("c:/webpages/db/BIGIPS.mdb"))
rs6.Open "SELECT name ,f5 FROM virtual_servers order by f5 asc",conn1
%>
switch(p_index)
<%
do until rs6.eof
startauthor=rs6("f5")
cnt=0
%>


case "<%=startauthor%>":
<%
do until rs6.eof or startauthor<>rs6("f5")
%>
alert("hi")
p_sub.options.length=0;
document.f1.subcat.options[<%=cnt%>]=new Option("<%=rs6("name")%>","<%=rs6("name")%>");
<%
cnt=cnt+1
rs6.movenext
if rs6.eof then exit do
loop
%>
break;
<%
loop
rs6.close
set rs6=nothing
%>
}
return true;
}
</script>
</head>






}

</head>




<body>





<h2 class="pos_abs">Title Comes Here</h2><br><br><br>


<br>
<div class="boxtest"></div>

<DIV class=box >



<DIV class=round-tl>

<DIV class=round-tr>
<DIV class=round-bl>
<DIV class=round-br><p>


<%
'These connections are for pulling data from DB and storing into Arrays when page loads
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("c:/webpages/db/BIGIPS.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
set rs1=Server.CreateObject("ADODB.recordset")
set rs2=Server.CreateObject("ADODB.recordset")
rs.Open "Select * from bigips order by name ", conn
rs1.open "select name,ipaddress,port from virtual_servers order by name",conn
rs2.open "select name,pool,port from nodes" ,conn
tablevalues1=rs.getrows
tablevalues2=rs1.getrows
tablevalues3=rs2.getrows
numrows1=ubound(tablevalues2,1)
numcols1=ubound(tablevalues2,2)
numrows=ubound(tablevalues1,1)
numcols=ubound(tablevalues1,2)
numrows2=ubound(tablevalues3,1)
numcols2=ubound(tablevalues3,2)



' Once the Data is stored in Arrays, destrying the objects that are not needed.
rs.close
rs1.close
rs2.close
set rs=nothing
set rs1=nothing
set rs2=nothing
conn.close
set conn=nothing





dim i,j
' this is for storing the default value in the drop down
dim default
default="None Selected"
default_for_bigip="Release All"




%>
<br><table>
<tr><td>
Big IP<td><form name="f1" method=post action="" >
<select name="category" id="category" onchange="javascript:readfdb(this.options[this.selectedIndex].value,this.form.subcat);"><option value="<%=default_for_bigip%>" selected><%=default_for_bigip%></option>

<%

for j=0 to numcols



Response.Write "<option VALUE=" & tablevalues1(0,j) & _
">" & tablevalues1(0,j) & "</OPTION>"

Response.Write("<br >")
next

%>
</select><tr><td>
Virtual Server Address
<td>
<select name="subcat" id="subcat">
<option value="<%=default%>" selected><%=default%></option>
<%
for i=0 to numcols1


Response.Write("<option>"& tablevalues2(1,i) )

Response.Write("<br >")
next

%>
</select ><tr><td>Virtual Server Port
<td><select name="userid" >
<option value="<%=default%>" selected><%=default%></option>
<%
for i=0 to numcols1


Response.Write("<option>"& tablevalues2(2,i))

Response.Write("<br >")
next

%>
</select><tr><td>
Pool<td><select>
<option value="<%=default%>" selected><%=default%></option>
<%
for i=0 to numcols2


Response.Write("<option>"& tablevalues3(1,i))

Response.Write("<br >")
next

%>
</select><tr><td>
Node Address
<td><select>
<option value="<%=default%>" selected><%=default%></option>
<%
for i=0 to numcols2


Response.Write("<option>"& tablevalues3(0,i))

Response.Write("<br >")
next

%>
</select><tr><td>Node Port<td><select>
<option value="<%=default%>" selected><%=default%></option>
<%
for i=0 to numcols2


Response.Write("<option>"& tablevalues3(2,i))

Response.Write("<br >")
next

%>
</select>
<tr><td><input type="submit" class="howto" ></td>
</table>
</form>
</p>

</DIV>
</DIV>
</DIV>
</DIV>
</div>

</body>
</html>


Thanks