Look at the 2nd example..
Sep 18, 2016
3
Level 3
Javascript popup with text input to post
I have a checkbox the user can change with a submit button which currently posts and updates that particular field. What I'd like to do, is when user clicks submit a popup will appear with a text area with user can input a string. I want both, the inputed text to post, as well as the value which was changed from the checkbox. I'd like a confirm and cancel button on the popup. Confirm will post the data and cancel will do nothing.
What is the best way to do this?
Level 3
I created a hidden input in my form and assigned the value to that field in JS.
HTML:
<input type="hidden" name="dischargeReason" id="setReasonForLeaving">
Javascript:
function reasonForLeaving() {
var reasonForLeaving = prompt("Reason for discharge?");
if(reasonForLeaving === null || reasonForLeaving == "") {
alert('Enter reason for discharge');
return false;
}
else if (reasonForLeaving != null) {
document.getElementById("setReasonForLeaving").value = reasonForLeaving;
return true;
}
}
Please or to participate in this conversation.