I have added the code below to popup a form with three options and I’m capturing the result of my selection in modal.result.
The form displays correctly:
But based on my code I expect modal.result to be A, B or C based on my selection. Instead I get this when I display modal.result:
What am I doing wrong?
if (data.msg.addbrand && data.msg.addbrand != '') {
var msg = 'The brand ' + brand + ' is unknown. What would you like to do?';
const resources = [
{ name: " Accept item and add brand", id: "A" },
{ name: " Accept item but do not add brand", id: "B" },
{ name: " Cancel", id: "C" },
];
const form = [
{
name: msg,
id: "resource",
options: resources,
type: "radio",
},
];
const data = {
resource: "A",
};
(async function() {
const modal = await DayPilot.Modal.form(form, data);
alert(modal.result);
if (modal.result == 'A') {
var addbrand = "yes";
acceptitemconfirmed1(addbrand);
} else if (modal.result == 'B') {
var addbrand = "no";
acceptitemconfirmed1(addbrand);
} else {
$(location).attr("href", "item_edit_review.php?id="+item_id);
}
})();
} else {
addbrand = "no";
acceptitemconfirmed1(addbrand);
}