Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript How to do the right code of comparing two objects in pure/native JavaScript?

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #177162
    web_editor
    Participant

    What 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

    Link of complete code of two data (1 and 2)

    #177170
    web_editor
    Participant

    How? Can you please do it with my existing code? Sorry, I’m not familiar and not really a programmer

    #177173
    web_editor
    Participant

    Ops. 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

    #177176
    web_editor
    Participant

    Here’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>
    #177178
    web_editor
    Participant

    Html 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;
    #177445
    web_editor
    Participant

    But I don’t have privilege to change the entire html

    #177537
    __
    Participant

    Well 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.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.