I want to create a radio button with onclick function so when the user change status from open to close promp and alert message and asking for a reason, we have it on html + javascript and working fine so when we try to make it rails way, we put as default value open :checked => true so when we put the onclick: "comfirm();" rails ignore ** <%= radio_button_tag(:status, "Open", :checked => true) %>
** and put as checked the Close
<%= radio_button_tag(:status, "Open", :checked => true) %>
<%= label_tag(:status_ticket, "Open", id: "open") %>
<%= radio_button_tag(:status, "Close") %>
<%= label_tag(:status_ticket, "Close", id: "close") %>
but when i want to add the on click function broke the thing
ignore the :checked => true and set as checked the close
like so
<%= radio_button_tag(:status, "Open", :checked => true) %>
<%= label_tag(:status_ticket, "Open", id: "open") %>
<%= radio_button_tag(:status, "Close", onclick: "comfirm();") %>
<%= label_tag(:status_ticket, "Close", id: "close") %>
i don't think the function broke the things becouse is realy simple as you can see bellow
function comfirm() {
var result = prompt('Why do you want to close the ticket?: ');
document.getElementById("reason").value = result;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…