Jump to content

Both Js And Xml


Twango

Recommended Posts

so.i'm trying to have random jokes appear. inside i will have a tag with the number of jokes. and the jokeshere's the js

<script type="text/javascript" src="http://w3host.weebly.com/uploads/2/8/9/6/2896432/load.js"></script><script type="text/javascript">xmlDoc=loadXMLDoc("jokes.xml");nms=xmlDoc.getElentsByTagName("Num")[0]nc=Math.ceil( Math.random() * nms );x=xmlDoc.getElementsByTagName("s" + nc)[0]y=x.childNodes[0];m=y.nodeValue;alert(m);</script>

and the xml:<jokes><num>1</num><joke category="No Order"><s1>When life gives you skittles Throw 'em at random people and scream EAT THE RAINBOW!</s1></joke></jokes>

can you help? thanks!

Link to comment
Share on other sites

It is more helpful when you explain what goes wrong. Are you using your error console? I'm sure it would help.Make sure loadXMLDoc works synchronously, not asynchronouslynms=xmlDoc.getElentsByTagName("Num")[0]spell Elements correctlyIs <num> the total number of jokes? I hope so, if your randomizer is to work correctly

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...