I have a custom button and I am using a modal to prompt the user for input. There is a button that opens a new window url. The variable for the url is not formatting correctly.
custom button javascript:
{!REQUIRESCRIPT("/soap/ajax/34.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/34.0/apex.js")}
function insertScript(a) {
alert(a);
var body = '<h1>Select Office Name</h1>: ';
var list = sforce.apex.execute("DQCustomButtonUtils", "getProviderFacilities", {
id: "{!Contact.Id}"
});
var offices = JSON.parse(list);
var box = new SimpleDialog("hersh" + Math.random(), true);
parent.box = box;
box.setTitle("Please Select Service Office");
box.createDialog();
box.setWidth(350);
body += '<select>';
for (var office in offices) {
body += '<option value="' + offices[office].ww_Entity_Guid__c + '">' + offices[office].Name + '</option>' + '<br>';
}
body += '</select><br>';
body += "<button class='btn' onclick='window.parent.box.hide(); return false;'>Cancel</button>";
body += " ";
body += '<button class="btn" onclick="window.open("' + a + '"); return false;">OK</button>';
box.setContentInnerHTML(body);
box.setupDefaultButtons();
box.show();
}
var a = sforce.apex.execute('DQCustomButtonUtils', 'getProviderWindwardUrl', {
id: '{!Contact.Id}'
});
insertScript(a);
Alert showing variable a's url. This is correctly formatted:
How the button is actually written to the screen
<button class="btn" onclick="window.open(" http:="" localhost:53700="" provider.aspx?id="053659cc-cdde-45d6-826e-95cb787c005e&effdte=2003%2f10%2f01&termdte=12%2f31%2f9999");" return="" false;"="">OK</button>