getting info from class instances on the page

I want to compare the address values that I have in an array, to address values within all tags with a class name of .databaseAddress. If they match, I want to get the next sibling of the databaseAddress class instance, and get it's inner text value for an ID. Then, I want to send a get request out with the ID of the record that needs to be changed gained from the next sibling's inner text  and the order that the .databaseAddress class instance was found. So one query string variable of the get provides the record id of the record that needs to be updated, and the second variable provides a sort order value. So essentially, I want the sort order column in the database to match whatever sort order the page happens to have. I'm very close, but I'm doing something wrong. Here's my code

$.each($(".databaseAddress"), function (x, daddress) {
                $.each(addressesTrim, function (i, address) {
                    if (daddress == address) {
                        var id = $(this).next().text();
                        $.get(encodeURI("sortOrders.aspx?ID=" + id + "&sortOrder=" + x)); 
                    }

                });
            });

Open in new window


ASP.NET generated html
Response.Write("<div class='directionsAddress noDisplay'>" + directionsAddress + "</div>");
Response.Write("<div class='databaseAddress noDisplay'>" + databaseAddress + "</div>");

Open in new window


addressTrim is an array that is set earlier in the code, and I can see it contains the values I expect, so that's not the problem. The problem is getting the actual address value contained within each .databaseAddress, and going to it's next sibling and getting it's inner text for the ID. I tried daddress.text(), but that's not going to work. Seems like there is one small detail that I am missing, and any help would be greatly appreciated.
LVL 9
BobHavertyComhAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
Read comments in code:
$.each($(".databaseAddress"), function (x, daddress) {
                $.each(addressesTrim, function (i, address) {

                    // try changing the following two lines
                    if ( $(daddress).text() == address) {
                        var id = $(daddress).next().text();

                        // add this to see if you have the desired value
                        alert("Detected ID: " + id);

                        $.get(encodeURI("sortOrders.aspx?ID=" + id + "&sortOrder=" + x)); 
                    }

                });
            });

Open in new window


Regards,
Hielo
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.