Hello,
I added a HTML webresource in a CRM Form. When I try to run the javascript from a simple button it does not run anything, not even an simple alert.
What should I add to the code to be able to run the javascript from inside an html web resource?
Thanks for your help!
Angel
<!DOCTYPE html>
<html>
<body>
<img id="savings" src="test.png" style="padding-right:10px" >
<img id="creditcard" src="test1.png" style="padding-right:10px">
<img id="car" src="test2.png" style="padding-right:10px">
<img id="house" src="test3.png" style="padding-right:10px">
<button onclick="ProductImagesOnload()">Try it</button>
<script type="text/javascript">
function ProductImagesOnload() {
var grid = Xrm.Page.ui.controls.get('ProductsImages')._control;
alert(grid);
if (grid.get_innerControl() == null) {
setTimeout(subGridOnload, 1000);
return;
}
else if (grid.get_innerControl()._element.innerText.search("Loading") != -1) {
setTimeout(subGridOnload, 1000);
return;
}
var ids = grid.get_innerControl().get_allRecordIds();
for(i = 0; i < ids.length; i++) {
var x = grid.get_innerControl().getCellValue("rst_productclassid", ids[i]);
var flag = 0 ;
var flag1 = 0 ;
var flag2 = 0 ;
var flag3 = 0 ;
if (flag = 0){
if(x == "Deposit"){
document.getElementById("savings").src = "test4.png";
flag = 1;
}
}
if (flag1 = 0){
if(x == "Credit"){
document.getElementById("creditcard").src = "test5.png";
flag1 = 1;
}
}
}
}
</script>
</body>
</html>
*This post is locked for comments