Two linked dropodown boxes populated using remote scripting

Contributed by
Rating: 4 stars4 stars4 stars4 stars4 stars / 5
February 28, 2000
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

This is the remote scripting file used by RSCombos and RSTreeView.htm. Note:that with the remote scripting samples there is a hard-coded path to the relevant support files, this will have to be changed appropriately for people to get the demos to work on their own system. These demo's only work with Internet Explorer 5.0.

First Page--RSCombos.htm

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Two Combos using Remote Scripting</TITLE>
</HEAD>
<BODY>
<!-- Author: Adrian Forbes -->
<script language="JavaScript" src="../_scriptlibrary/rs.htm"></script>
<script language="JavaScript">RSEnableRemoteScripting("../_scriptlibrary");</script>
<p>
<select onChange="PopulateChildren()" name=cboParents ID=cboParent size=1>
&nbsp;</select><select name=cboChildren ID=cboChildren size=1></select>
</p>

<script language=VBScript>
strDBPage = "RSDatabase.asp"

sub Window_onLoad
PopulateParent
PopulateChildren
end sub

sub PopulateParent

set objParents = document.all("cboParents")
set objRS = RSExecute(strDBPage ,"GetDBParents")
sRS = objRS.return_value
aRows = Split(sRS, Chr(13))

for i = 0 to UBound(aRows) - 1
aFields = Split(aRows(i), ";")
set objOption = document.createElement ("OPTION")
objOption.Value = aFields(0)
objOption.Text = aFields(1)
objParents.add objOption
next
end sub

sub PopulateChildren
set objParents = document.all("cboParents")
set objChildren = document.all("cboChildren")
while objChildren.length > 0
objChildren.remove (0)
wend

set objRS = RSExecute(strDBPage ,"GetDBChildren", objParents.value)
sRS = objRS.return_value
aRows = Split(sRS, Chr(13))

for i = 0 to UBound(aRows) - 1
aFields = Split(aRows(i), ";")
set objOption = document.createElement ("OPTION")
objOption.Value = aFields(0)
objOption.Text = aFields(1)
objChildren.add objOption
next
end sub
</script>
</BODY>
</HTML>

Page 2 RSDatabase.asp

<%@ LANGUAGE=VBSCRIPT %>
<%
strconn =
"Driver={SQL Server};Description=sqldemo;SERVER=127.0.0.1;UID=LoginID;
PWD=Password;DATABASE=Database_Name
%>
<% RSDispatch %>
<!-- Author: Adrian Forbes -->
<!--#INCLUDE FILE="../_ScriptLibrary/rs.asp"-->
<SCRIPT RUNAT=SERVER Language=javascript>
function Description()
{
this.GetDBParents = Function( 'return GetDBParents()' );
this.GetDBChildren = Function('ID', 'return GetDBChildren(ID)' );
this.Method1 = Method1;
}
public_description = new Description();

function Method1()
{
return 'Test';
}
</script>

<SCRIPT RUNAT=SERVER Language=VBScript>
function GetDBParents()

set objRS = createobject("ADODB.Recordset")
objRS.Open "select ID, strParent from Parents", strconn
GetDBParents = objRS.GetString(, , ";")
objRS.Close
set objRS.ActiveConnection = nothing
set objRS = nothing

end function

function GetDBChildren(ID)

set objRS = createobject("ADODB.Recordset")
objRS.Open "select ID, strChild from Children WHERE intParent=" & ID, strconn
GetDBChildren = objRS.GetString(, , ";")
objRS.Close
set objRS.ActiveConnection = nothing
set objRS = nothing

end function
</SCRIPT>




blog comments powered by Disqus
CODE EXAMPLES ARTICLES

- Bipartite Graphs
- Connectivity in Graphs
- The Ford-Fulkerson Algorithm
- Critical Paths
- The Bellman-Ford and Roy-Floyd Algorithms
- Shortest Path Algorithms in Graphs
- Minimum Spanning Tree
- Articulation Edges and Vertexes
- Circles and Connectivity in Graphs
- Depth-First Search in Graphs
- Breadth-First Search in Graphs
- The Prufer Code and the Floyd-Warshall Algor...
- An Insight into Graphs
- Coding a Custom Object with WSC
- Creating a Custom Object with WSC

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 4 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials