I have a dataset I need to use to update values in an HTML table with javascript but I’m not sure what the best way to access the values in the dataset would be.
I thought I should try to load them into a two-dimensional array but I’m not certain how I would read the values into the array when the page loads. I can put the values into pretty much any type of table or delimited text file.
An example of the dataset:
101 1.2 1.3 1.4 null
102 1.3 1.4 1.5 null
103 1.6 1.7 null null
The dataset has 65 rows and will be needed for an onChange() event in the HTML. When a value in a certain input is changed on the page I would like to look at the dataset and use the value entered into the input to extract a value from the dataset which will be used to update the HTML.
I understand that javascript doesn’t support multidimensional arrays but I’ve found a lot of examples of people simulating them by nesting arrays within arrays, I was hoping to be able to do something similar to hold the dataset. This dataset isn’t very big so I considered simply writing it out in the script but I’m not sure how I would use it like that. I was hoping I could use some sort of read line routine to iterate through a text file and read the values into an array. If not from an external file then is there a way to include the values from the dataset in the script section and read them into an array when the page loads?
Please let me know if my thinking is completely off-base and there is a different way of accomplishing this. If this sounds like a reasonable approach I could really use some suggestions on how to read the data into the array when the page loads. I’m fairly new to javascript and haven’t tried accessing external files or anything so please excuse my ignorance. Thanks in advance for any help.