I have a JavaScript event that occurs on button click and the button cannot be clicked unless a choice is made (via radio buttons). I have a form with two radio buttons:
<input type="radio" id="lottery1" name="choice0" value="1" align="center" >A
<input type="radio" id="lottery2" name="choice0" value="2" align="center" >B
<input type="hidden" id="payoffr1" name="payoffr1" value=" " />
and this is the code for the button:<input id="start_button" type="button" value="Start" onClick="startEvent();">
In models.py I have:
choice0 = models.IntegerField()
After the function startEvent, there is another function that follows and displays a javaScript generated variable in the alert box:
function Prize(indicatedSlice)
{
payoffr1 = indicatedSlice.text.slice(-3);
document.getElementById("payoffr1").value = payoffr1;
alert("You have won " + payoffr1);
}
document.getElementById('thisForm').submit();
}
I tried to submit the form after clicking 'OK' on the alert box message by adding the last line in the function Prize, but it keeps me in the same page. How can I submit the form after a user clicks 'OK'? Any advice would be extremely helpful!