Whenever a user clicks on the getPrice button again and selects different input, I want to replace the iframe. Despite trying multiple approaches in my code, nothing seems to work out. Using document.body.appendChild() every time is not an option for me. Can someone please provide guidance on this issue?
function getPrice(){
var ifrm = document.createElement('iframe');
ifrm.id = "frameID";
ifrm.setAttribute('src', 'http://40.85.176.227/invoke/Tier1ICLStd_New.Price/getPrice?CloudName=Azure East');
ifrm.setAttribute('align', 'right');
ifrm.style.margin = "auto";
ifrm.scrolling = "no";
ifrm.style.border = "0";
ifrm.style.margin = "0";
if(document.getElementById("frameID") == null){
document.body.appendChild(ifrm);
} else {
alert("Else"); // I am getting control till here but what code to replace the existing iframe.
//var item = document.getElementById("frameID").childNodes[0];
item.replaceChild(ifrm, item.childNodes[0]);
alert("test");
document.body.appendChild(ifrm);
//ifrm.parentNode.replaceChild(ifrm, ifrm);
}
}