3
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by ksquared
0

What are the values of the array? And which item in the array do you want to pass to a variable?

0
function captionToDiv() {
document.getElementById("captionHere").innerHTML = captionsList[caption];
return false;
}

This code does not work. If I could pass captionsList[caption] to a variable, maybe it would then work.?

0

Thanks! I was able to create an array from text. Would you like the code?

0

you maybe did emulation of associative array?

In the article it says that its possible.

Javascript does not have, and does not support Associative Arrays. However… All arrays in Javascript are objects and Javascript's object syntax gives a basic emulation of an associative Array.

Yeah, would be interesting to see a code.

0

I had lots of help with this.

<script type="text/javascript">
		function captionsToCaptionsList() {
		try{
			txtFile = new XMLHttpRequest();
		}
		catch(e){
			try{
				txtFile = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e) {
				try{
					txtFile = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch(e){
					alert("Ajax not supported by your browser!");
					return false;
				}
			}
		}
		txtFile.open("GET", "paintinglist.txt", true);
		txtFile.onreadystatechange = function() {
			if (txtFile.readyState === 4) {// Makes sure the document is ready to parse.
				if (txtFile.status === 200) {// Makes sure it's found the file.
					captionsList = txtFile.responseText.split("\n"); 
}
}
}
txtFile.send(null);
}
captionsToCaptionsList();
</script>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.