I am currently utilizing a third party web-based application that allows for UI script injection.
Within the page I am trying to inject my UI script into are a list of elements with associated checkboxes. The following are checkboxes generated by the webpage by the original developers, I cannot change these:
<input type="checkbox" value="1" class="selectionCheckbox" checked="checked" onclick="foo(this)"> // For True (Checked)
<input type="checkbox" value="1" class="selectionCheckbox" onclick="foo(this)"> // For False (Unchecked)
I am trying to load their values into my own UI Script's checkboxs after the document is ready. The nature of my script is basically to inject a X/Y Grid of combinations instead of a list.
I have tried:
function loadCheckOne(vobj, objValue) {
var containerObj = document.getElementById(objValue);
var row = containerObj.getElementsByClassName("checkbox");
// row[0] === the above mentioned input element
if (row[0].checked){
vobj.setAttribute("checked", "true");
console.log("Marked.");
}
console.log(row[0].checked); // Prints: "undefined"
}
function loadCheckTwo(vobj, objValue) {
var containerObj = document.getElementById(objValue);
var row = containerObj.getElementsByClassName("checkbox");
// row[0] === the above mentioned input element
if (row[0].hasAttribute("checked")){
vobj.setAttribute("checked", "true");
console.log("Marked.");
}
console.log(row[0].hasAttribute("checked")); // Prints: "false"
}
function loadCheckThree(vobj, objValue) {
var containerObj = document.getElementById(objValue);
var row = containerObj.getElementsByClassName("checkbox");
// row[0] === the above mentioned input element
if (row[0].getAttribute("checked")){
vobj.setAttribute("checked", "true");
console.log("Marked.");
}
console.log(row[0].getAttribute("checked")); // Prints: "null"
}
The problem is all methods return false or null in some fashion, even for checkboxes that are checked at runtime of the script. Not sure where to go from here.