As a newcomer to JavaScript, I've been encountering difficulties when it comes to transferring information extracted from a custom-built array into a text box. My current approach involves using Dashcode and tweaking elements within the main.js
file as needed. While I have successfully created an array and can access values stored within it, I'm struggling to populate the text box with this data.
The specific line causing issues is:
document.getElementById("text").setAttribute("text", textLocation);
In this snippet, text
refers to the ID of the target text box, and textLocation
represents the content I aim to insert into it.
Your assistance on this matter would be greatly appreciated.
Below you will find the remainder of the code:
var n = null;
var textLocation;
var myArray = new Array("info one","info 2","info 3","info 4","info 5","info 6","info 7","info 8","info 9");
function toPreviousImage(event) {
var list = document.getElementById("grid").object;
var selectedObjects = list.selectedObjects();
var name = selectedObjects[0].valueForKey("name");
var textinfo = selectedObjects[0].valueForKey("info");
name= name - 1;
if(!n || n == undefined){n=name} else {n--}
textLocation = myArray[n];
document.getElementById("text").setAttribute("text", textLocation);