<tr>
**<td>**JB - Al Qouz**</td>**
**<td>**
<strong>0</strong>
<input type="hidden" name="ingredient[inventories_attributes][][id]" id="ingredient_inventories_attributes__id" value="5564069">
<small><span class="buyUnitValueText ">pc</span></small>
<small><b><span id="totalStockValue_1" class="hide paddingLeft15 updateTotalStockValue"></span></b></small>
**</td>**
**<td>**
<div class="align-left">
<input type="text" name="ingredient[inventories_attributes][][reorder_level]" id="ingredient_inventories_attributes__reorder_level" value="0" class="span5 menuItemInventory reOrderValue">
<small><span class="buyUnitValueText span7 labelText pull-right align-left">pc</span>
</small>
</div>
**</td>**
<td class="align-left">
<input type="hidden" name="ingredient[inventories_attributes][][track_inventory]" id="track_inventory_9971" **value="true"**>
**<div class="vCheckBox trackInventoryCheckbox active" id="9971"></div>**
I need to change 2 things (See Bold) if "id=9971"
through vba.
vCheckBox trackInventoryCheckbox active
to class vCheckBox trackInventoryCheckbox
value="true"
to value="false"
Reason being, I'm not able to click the button through VBA and the code change in html that occurs when I click manually are the 1. & 2. mentioned above.
Please advise, below is my code where I tried to get tag value through tr
but couldn't, second part was where I could change the values.
With ie
.Visible = True
.navigate (EditIngredientURL)
While .Busy Or .readyState <> 4: DoEvents: Wend
While .document.readyState <> "complete": DoEvents: Wend
End With
Set HTMLdoc = ie.document
Set tr = HTMLdoc.getElementsByTagName("tr")
For Each trObj In tr
Set td = trObj.getElementsByTagName("td")
For Each tdObj In td
If InStr(tdObj.innerText, "JB - Al Qouz") Then
Debug.Print tdObj.innerText
Set CheckBox = tdObj.getElementsByTagName("class")
For Each idnumber In CheckBox
Debug.Print idnumber.innerText
Exit For
Next
End If
Next
Next
End Sub
If the ID is known and you have it in a variable idNo
you can use it to locate the elements:
idNo = "9971"
HTMLdoc.getElementById("track_inventory_" & idNo).value = "false"
HTMLdoc.getElementById(idNo).className = "vCheckBox trackInventoryCheckbox"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.