I have the below Table TDs that I need to get the values.
<table style="border: 1px solid blue;margin: 15px;">
<tr>
<td class="drdsclient">DSCDS201020101</td>
</tr>
<tr class="drcheck">
<td>Maximum online generations:</td>
<td id="drcheckval" class="notopborder">30</td>
<td id="drchecknotes" class="notopborder">notes</td>
</tr>
<tr class="drcheck">
<td>Default Retention Rule set:</td>
<td id="drcheckval" class="notopborder">No default Retention rule set</td>
<td id="drchecknotes" class="notopborder">notes</td>
</tr>
<tr class="drcheck">
<td>Default Backup Schedule set:</td>
<td id="drcheckval" class="notopborder">No default Schedule set</td>
<td id="drchecknotes" class="notopborder">notes</td>
</tr>
<tr class="drcheck">
<td class="drdsclient">DSCDS901999102</td>
</tr>
<tr class="drcheck">
<td>Maximum online generations:</td>
<td id="drcheckval" class="notopborder">29</td>
<td id="drchecknotes" class="notopborder">notes</td>
</tr>
<tr class="drcheck">
<td>Default Retention Rule set:</td>
<td id="drcheckval" class="notopborder">30 days</td>
<td id="drchecknotes" class="notopborder">notes</td>
</tr>
<tr class="drcheck">
<td>Default Backup Schedule set:</td>
<td id="drcheckval" class="notopborder">Monday to Friday @ 21:00</td>
<td id="drchecknotes" class="notopborder">notes</td>
</tr>
</table>
I keep using IDs and Classes with the below JS code:
var array1 = [];
$(' .drdsclient ').each(function(){
var obj = {
drdsc: $(" .drdsclient ").text(),
drcheck1: $(" #drcheck1 " ).text(),
drcheckval1: $(" #drcheckval1 ").text(),
drchecknotes1: $(" #drchecknotes1 ").text(),
drcheck2: $(" #drcheck2 " ).text(),
drcheckval2: $(" #drcheckval2 ").text(),
drchecknotes2: $(" #drchecknotes2 ").text(),
drcheck3: $(" #drcheck3 " ).text(),
drcheckval3: $(" #drcheckval3 ").text(),
drchecknotes3: $(" #drchecknotes3 ").text()
};
var arr2 = array1.push(obj);
});
But instead of appending to the array, it doubles the values and I get the below result:
[0]
[drdsc] => "DSCDS201020101DSCDS901999102"
[drcheck1] => "Maximum online generations:Maximum online generations:"
[drcheckval1] => "30999"
[drchecknotes1] => "notesnotes"
[drcheck2] => "Default Retention Rule set:Default Retention Rule set:"
[drcheckval2] => "No default Retention rule set30 days"
[drchecknotes2] => "notesnotes"
[drcheck3] => "Default Backup Schedule set:Default Backup Schedule set:"
[drcheckval3] => "No default Schedule setMonday to Friday @ 21:00"
[drchecknotes3] => "notesnotes"
[1]
[drdsc] => "DSCDS201020101DSCDS901999102"
[drcheck1] => "Maximum online generations:Maximum online generations:"
[drcheckval1] => "30999"
[drchecknotes1] => "notesnotes"
[drcheck2] => "Default Retention Rule set:Default Retention Rule set:"
[drcheckval2] => "No default Retention rule set30 days"
[drchecknotes2] => "notesnotes"
[drcheck3] => "Default Backup Schedule set:Default Backup Schedule set:"
[drcheckval3] => "No default Schedule setMonday to Friday @ 21:00"
[drchecknotes3] => "notesnotes"
Any way I can get an array like the below?
[0]
[drdsc] => "DSCDS201020101"
[drcheck1] => Maximum online generations:"
[drcheckval1] => "30"
[drchecknotes1] => "notes"
[drcheck2] => "Default Retention Rule set:"
[drcheckval2] => "No default Retention rule set"
[drchecknotes2] => "notes"
[drcheck3] => "Default Backup Schedule set:"
[drcheckval3] => "No default Schedule set"
[drchecknotes3] => "notes"
[1]
[drdsc] => "DSCDS901999102"
[drcheck1] => "Maximum online generations:"
[drcheckval1] => "999"
[drchecknotes1] => "notes"
[drcheck2] => "Default Retention Rule set:"
[drcheckval2] => "30 days"
[drchecknotes2] => "notes"
[drcheck3] => "Default Backup Schedule set:"
[drcheckval3] => "Monday to Friday @ 21:00"
[drchecknotes3] => "notes"