Make your own free website on Tripod.com
Assignment 8

<%@language = vbscript%>

<%option explicit%>

<html>

<head>

<script language="Javascript">

function refreshMakesSelectOptions() {

document.all.makesSelect.options.length = 0;

document.all.makesSelect.options[0] = new Option();

document.all.makesSelect.options[0].value = -1;

document.all.makesSelect.options[0].text = "Select A Make";

var oNodeList = makesAndModelsXMLDoc.getElementsByTagName("make")

for (var i = 0; i < oNodeList.length; i++) {

var oNodeMake = oNodeList.nextNode();

document.all.makesSelect.options[i+1] = new Option();

document.all.makesSelect.options[i+1].value = oNodeMake.selectSingleNode("makeid").text;

document.all.makesSelect.options[i+1].text = oNodeMake.selectSingleNode("makename").text;

}

}

function refreshModelsSelectOptions() {

document.all.modelsSelect.options.length = 0;

document.all.modelsSelect.options[0] = new Option();

document.all.modelsSelect.options[0].value = -1;

document.all.modelsSelect.options[0].text = "Select A Model";

var oNodeList =

makesAndModelsXMLDoc.getElementsByTagName("make[makeid='" + document.all.makesSelect.value + "']/model");

for (var i = 0; i < oNodeList.length; i++) {

var oNode = oNodeList.nextNode();

document.all.modelsSelect.options[i+1] = new Option();

document.all.modelsSelect.options[i+1].value = oNode.selectSingleNode("modelid").text;

document.all.modelsSelect.options[i+1].text = oNode.selectSingleNode("modelname").text;

}

}

</script>

</head>

<body onload = "refreshMakesSelectOptions()">

<select name = "makesSelect" onchange = "refreshModelsSelectOptions()">

</select>

<br><br>

<select name = "modelsSelect">

</select>

<br><br>

<xml id = "makesAndModelsXMLDoc" src = "Assignment8-1.asp">

</xml>

</body>

</html>

Assignment 8.1

<%@language = vbscript%>

<%option explicit%>

<%response.expires = 0%>

<?xml version = "1.0"?>

<makes>

<%dim oconn, ors, strquery, strPreviousMake

set oconn = server.createobject("ADODB.Connection")

set ors = server.createobject("ADODB.Recordset")

oconn.open("CIS350ASsignment8")

strquery = "select * from MakesAndModels order by makename, modelname"

ors.open strquery, oconn

strPreviousMake = ""

while not ors.eof

if strPreviousMake <> ors("MakeID") then

if strpreviousMake <> "" then

response.write("</make>")

end if

response.write("<make>")

response.write("<makeid>" & ors("MakeID") & "</makeid>")

response.write("<makename>" & ors("makename") & "</makename>")

end if

if ors("modelid") <> "" then

response.write("<model>")

response.write("<modelid>" & ors("modelid") & "</modelid>")

response.write("<modelname>" & ors("modelname") & "</modelname>")

response.write("</model>")

end if

strPreviousMake = ors("makeid")

ors.MoveNext

wend %>

</make>

<%ors.close

oconn.close

set ors = nothing

set ors = nothing %>

</makes>