开发者

capture the elements in a text area box with a button, and put them into an array in memory

开发者 https://www.devze.com 2023-04-04 20:55 出处:网络
I\'m attempting to write a huge array in the computer memory and then save the final output as .json, but i\'开发者_如何学编程m having trouble writing a script that will continually update an array on

I'm attempting to write a huge array in the computer memory and then save the final output as .json, but i'开发者_如何学编程m having trouble writing a script that will continually update an array on my page that will sit in the browsers memory until the user is ready to save their final .json file.

I have 3 form elements on my page that will do this. A combobox, textarea & button.

The user will hit the page, and select an option from the combobox. They will then put some numbers in the textarea field. they will then click a button, and those numbers will be stored in an array that is continually updated in memory.

i'm not too sure of the rules here, but i've started writing some code on jsfiddle that will do this: http://jsfiddle.net/PJ7s6/4/

From my understanding, I would want to loop through my original array, and use .val() or something of the sort to capture the id on the node, then go into my array, and find the "section" associated with that ID, then write the text from the textarea into the "array: [] value in my response.

Has anyone done anything like this before?

I've only been at this jquery, json, looping stuff for about 6 months and i'm finally starting to get it. I appreciate everyone that has given me support during this trek!


From our conversation in the comments, it doesn't sound like you actually have an issue to worry about. Browser memory will be fine for the task at hand. It does sound like you need to learn a bit about javascript array and object manipulation.

The basic way to add to an array is push:

var your_array = []; // an empty array
your_array.push( 'red', 'orange', 'yellow' );
your_array.push( 'green', 'blue', 'purple' );

your_array would now include all 6 colors. It gets more complex than that, but that's the basic start.

From here, I'd ask more questions (read: new questions on SO) that are more specific to your current needs, and hopefully you'll get more help!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号