XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 29th, 2004, 03:50 PM
ramsateesht ramsateesht is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 3 ramsateesht User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Problem with vbscript/xmlDOM

This is my html code in which I am using a vb script. this whole code is being generated by a cgi written in Perl. But I am getting errors just download the code and place a sample xml file as given below and try browsing the page.

#####################HTML FILE##################

<html>
<head>
<title> This is the C1 Question Bank </title>
<script type='text/vbscript'>
function evaluate(xmlDoc)
set answers = xmlDoc.getElementsByTagName("answer")
Dim useranswers(100)
Dim i,j,k
For i = 0 to answers.length-1
For j = 0 to Document.exam.Elements.Count-1
If Document.exam.Elements(j).Name = (i+1) Then
useranswers(i) = Document.exam.Elements(j).Value
End if
Next j
Next i
Dim Score = 0
For k = 0 to answers.length-1
If useranswers(k) = answers(k) Then
Score++
End if
Next
msgbox " Your Score is : " & Score
end function
</script>
</head>
<body>
<script type="text/vbscript">
set xmlDoc=CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("C1.xml")
set x1 = xmlDoc.getElementsByTagName("number")
set x2 = xmlDoc.getElementsByTagName("question")
set x3 = xmlDoc.getElementsByTagName("choice1")
set x4 = xmlDoc.getElementsByTagName("choice2")
set x5 = xmlDoc.getElementsByTagName("choice3")
set x6 = xmlDoc.getElementsByTagName("choice4")
document.write("<form name=exam action=submit.cgi method=GET> ")
document.write(" <input type=hidden name=id value=82877807617188 ></input> ")
document.write(" <b> ")
for i = 1 to x1.length
document.write("<br><br>")
document.write(" <pre> ")
document.write(x1.item(i-1).text)
document.write(". ")
document.write(x2.item(i-1).text)
document.write(" </pre> ")
document.write("<br><br>")
document.write("<font color=blue> ")
document.write(" <pre> ")
document.write("1. ")
document.write("<input type=radio name=")
document.write(x1.item(i-1).text)
document.write(" value=1>")
document.write(x3.item(i-1).text)
document.write("</input>")
document.write(" </pre>")
document.write(" <pre>")
document.write(" 2. ")
document.write(" <input type=radio name=")
document.write(x1.item(i-1).text)
document.write(" value=2>")
document.write(x4.item(i-1).text)
document.write("</input>")
document.write(" </pre>")
document.write(" <pre>")
document.write(" 3. ")
document.write(" <input type=radio name=")
document.write(x1.item(i-1).text)
document.write(" value=3>")
document.write(x5.item(i-1).text)
document.write("</input>")
document.write(" </pre>")
document.write(" <pre>")
document.write(" 4. ")
document.write(" <input type=radio name=")
document.write(x1.item(i-1).text)
document.write(" value=4>")
document.write(x6.item(i-1).text)
document.write("</input>")
document.write(" </pre></font>")
document.write("<br>")
next
document.write(" </b> ")
document.write(" <input type=button value=Submit onClick='evaluate(xmlDoc)'> </input> ")
document.write(" </form> ")
</script>
</body>
</html>

#####################XML FILE####################

<?xml version="1.0" encoding="ISO-8859-1"?>
<questionbank>
<questions>
<number>1</number>
<question>
This is a sample question
</question>
<choice1>
Compilation error at Step3
</choice1>
<choice2>
Compilation error at Step2
</choice2>
<choice3>
file1: 10
</choice3>
<choice4>
main : 10
</choice4>
<answer>4</answer>
</questions>
</questionbank>

Thanks in advance

Ram

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Problem with vbscript/xmlDOM


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT