jquery - Javascript alert cancel button not working in safari -


i'm trying set sequence of events when user click on radio button triggers form submit. in addition, want give user java warning asking them confirm selection click ok, redirect php page, or cancel , stay on current page , nothing. have, reason when user click cancel on alert in safari, form still submits.

is radio onclick conflicting actual script? how add alert script?

<form name="confirmform" id="confirmform" method="post" action="update_confirm.php">  <div id="confirmgroup">  <input type="radio" name="email_confirm" id="emailgroup1" value="verify" class="verify" onclick="return confirm('update email status?');" > <label class="emailgroup" for="emailgroup1">verify</label>  <input type="radio" name="email_confirm" id="emailgroup2" value="good" class="good" onclick="return confirm('update email status?');" > <label class="emailgroup" for="emailgroup2">good</label>  <input type="radio" name="email_confirm" id="emailgroup3" value="bad" class="bad" onclick="return confirm('update email status?');" > <label class="emailgroup" for="emailgroup3">bad</label>  </div> </form> 

--

<script>      $("#confirmform").change(function()     {     document.getelementbyid("confirmform").submit();     }); </script> 

you need add confirm in jquery change event:

$("#confirmform").change(function() {    if (confirm('are sure of selection?')) {      document.getelementbyid("confirmform").submit();    }  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <form name="confirmform" id="confirmform" method="post" action="update_confirm.php">      <div id="confirmgroup">        <input type="radio" name="email_confirm" id="emailgroup1" value="verify" class="verify" onclick="return confirm('update email status?');">      <label class="emailgroup" for="emailgroup1">verify</label>        <input type="radio" name="email_confirm" id="emailgroup2" value="good" class="good" onclick="return confirm('update email status?');">      <label class="emailgroup" for="emailgroup2">good</label>        <input type="radio" name="email_confirm" id="emailgroup3" value="bad" class="bad" onclick="return confirm('update email status?');">      <label class="emailgroup" for="emailgroup3">bad</label>      </div>  </form>


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -