Home › Forums › JavaScript › How to do the right code of comparing two objects in pure/native JavaScript?
- This topic is empty.
-
AuthorPosts
-
July 31, 2014 at 10:58 pm #177162
web_editor
ParticipantWhat is the right code in pure/native JavaScript, if the data 1 and data 2 are both different, there will be 2 new tab will open? But if the data 1 and data 2 have same value, there’s only 1 new tab will open? I have a script of comparing the values of data 1 and data 2, but I don’t know how to do the right and proper code of comparing 2 objects. I read articles and questions in stackoverflow. But still I don’t understand how to do that.
E.g. When the values of data 1 is the same of values in data 2, there’s an confirmation box will pop up and open new tab.
But when data 1 and 2 are both different values there’s a two confirmation box will pop up, first is for data 1 and open new tab. Second, for data 2 and open new tab again (for data 2)Please help me. I’m a newbie in JavaScript. Thank you
Link of code of comparing of two values with open a new tabs
August 1, 2014 at 1:23 am #177170web_editor
ParticipantHow? Can you please do it with my existing code? Sorry, I’m not familiar and not really a programmer
August 1, 2014 at 1:43 am #177173web_editor
ParticipantOps. Sorry, I dont know how to combine it with html. Btw, i have a screenshot of data/values that I need to compare, Contact Address and Permanent Address print screen
August 1, 2014 at 2:21 am #177176web_editor
ParticipantHere’s some of html tag of Contact Address
<tr class="row-parent categoryName evenRow"> <td colspan="2"><span>Contact address</span></td> </tr> <tr class="row-parent oddRow" id="id4a50"> <td><span>Barangay</span></td> <td><span>Barangay 105</span></td> </tr> <tr class="row-parent evenRow" id="id4a52"> <td><span>ZIP Code</span></td> <td><span>1402</span></td> <td><div class="history-cont"></div></td> </tr>
August 1, 2014 at 2:38 am #177178web_editor
ParticipantHtml tag for Permanent address
<tr class="row-parent categoryName evenRow"> <td colspan="2"><span>Permanent address</span></td> </tr> <tr class="row-parent oddRow" id="id4b48"> <td><span>Province</span></td> <td><span>Caloocan City</span></td> </tr>
Do you mean the div css container? If yes, here..
width: 100%; height: 100%; min-width: 840px; min-height: 400px; max-height: 680px;
August 3, 2014 at 7:43 pm #177445web_editor
ParticipantBut I don’t have privilege to change the entire html
August 4, 2014 at 9:46 am #177537__
ParticipantWell I usually write this kind of stuff with jQuery, but if you want native js I think I might need a selector for each container.
If you’re mainly using jQuery for its selector capabilities, be aware that
document.querySelectorAll
has very good support. -
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.