In this article , I am going to explain how to insert button using javascript on CRM Form along with attribute like below image
Call this function on Form onload event and pass attribute name as parameter
function addButton(attributename) {
if (document.getElementById(attributename) != null) {
var sFieldID = "field" + attributename;
var elementID = document.getElementById(attributename + "_d");
var div = document.createElement("div");
div.style.width = "19%";
div.style.textAlign = "right";
div.style.display = "inline";
elementID.appendChild(div, elementID);
div.innerHTML = '<button id="' + sFieldID + '" type="button" style="margin-left: 4px; width: 100%;" ><img src="/_imgs/ico_16_4210.gif" border="0" alt="Dial this number"/></button>';
document.getElementById(attributename).style.width = "80%";
document.getElementById(sFieldID).onclick = function () {onbuttonclick(); };
}
}
function onbuttonclick() {
alert('Hi');
}
Call this function on Form onload event and pass attribute name as parameter
function addButton(attributename) {
if (document.getElementById(attributename) != null) {
var sFieldID = "field" + attributename;
var elementID = document.getElementById(attributename + "_d");
var div = document.createElement("div");
div.style.width = "19%";
div.style.textAlign = "right";
div.style.display = "inline";
elementID.appendChild(div, elementID);
div.innerHTML = '<button id="' + sFieldID + '" type="button" style="margin-left: 4px; width: 100%;" ><img src="/_imgs/ico_16_4210.gif" border="0" alt="Dial this number"/></button>';
document.getElementById(attributename).style.width = "80%";
document.getElementById(sFieldID).onclick = function () {onbuttonclick(); };
}
}
function onbuttonclick() {
alert('Hi');
}
great stuff...
Reply DeleteYou should put a disclaimer...This is unsupported customization and should be avoided unless and until absolutely required. As a general rule anywhere getElementById is used we should be avoiding that.
Reply DeleteOK Abhishek , Thanks for your advice :)
Reply Delete