Skip to content
October 18, 2010 / Danii Oliver

Arrays

My biggest challenge now is to find a way to push dynamic variables to an array, which I have done. Then search that array for the name of a selected target that I wont know the name of until it is selected. Once selected I need to find a way to search my array for any previous indexes of that name and delete it.

Or be able to select and deselect and not record until the submit button has been selected.

I know what the logic is for what I need to get done however, I don’t know or can’t find the tools to get it done. Previously I created a search and replace pattern known as a RegExp but, RegExp is not a dynamic string or data type. It is a literal string that cannot be changed. I cannot program hard coded RegExp’s because my searches could be any where from 0 to 100 or more at any time. If I hard code I trap myself in the long-run.

Is it worth it to setup a shot term solution to maintain long term support? Is that ethical?

What’s more important, getting the job done or getting the work done?

So, this is what I figured…

Find the index of the target if true push to the array

if false go to the index of when it was true then splice it and only that one.

e.target.selected == true;

if (e.target.selected == true)

{

chkArray.push(e.target.name)

trace (chkArray.indexOf(e.target.name))

}

else

{

trace (chkArray.indexOf(e.target.name))

chkArray.splice(chkArray.indexOf(e.target.name),1)

}

It worked!

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: