freaker87 Posted December 15, 2011 Share Posted December 15, 2011 Hello Frnds, I have code which i am using for update a file ..... $poid = $_POST['txtpoid']; $suppid = $_POST['suppid']; $custid = $_POST['custid']; $podate = $_POST['timestamp']; $poqty = $_POST['txtpoqty']; $chkqty = $_POST['chkqty']; if($chkqty<>$poqty) { ////HERE I WANT TO SHOW CONFIRM JAVASCRIPT WITH YES/NO OPTION (YOU ARE GOING TO CHANGE QUANTITY. ARE YOU SURE), IF YES THE QUERY UPDATE IF NOTHEN EXIT FROM HERE SO WHATS THE CODE PLZ HELP///////////// } $query = ("update po SET suppid='$suppid',custid='$custid,podate='$podate',poqty='$poqty' where poid='$poid'"); if(!mysql_query($query, $link)) die ("Mysql error ....<p>".mysql_error()); Link to comment https://forums.phpfreaks.com/topic/253224-php-javascript-confirm-msg-help/ Share on other sites More sharing options...
jotorres1 Posted December 15, 2011 Share Posted December 15, 2011 If I were you, I would use the confirm on the form submit. <form method="POST" action="yourpage.php" id="submitform" name="submitform"> <input type="Submit" name="Submit" value="Submit" onClick="return confirmSubmit()"> </form> The javascript should look like this: <script LANGUAGE="JavaScript"> <!-- function confirmSubmit() { var poqty = document.getElementById('txtpoqty'); var chkqty = document.getElementById('chkqty'); if(poqty != chkqty){ var agree=confirm("YOU ARE GOING TO CHANGE QUANTITY. ARE YOU SURE?"); if (agree) return true ; else return false ; } } return true; // --> </script> Link to comment https://forums.phpfreaks.com/topic/253224-php-javascript-confirm-msg-help/#findComment-1298258 Share on other sites More sharing options...
freaker87 Posted December 16, 2011 Author Share Posted December 16, 2011 Yes I can use this but your script not working... what should i do now? Link to comment https://forums.phpfreaks.com/topic/253224-php-javascript-confirm-msg-help/#findComment-1298455 Share on other sites More sharing options...
jotorres1 Posted December 16, 2011 Share Posted December 16, 2011 What error are you getting? Link to comment https://forums.phpfreaks.com/topic/253224-php-javascript-confirm-msg-help/#findComment-1298483 Share on other sites More sharing options...
jotorres1 Posted December 19, 2011 Share Posted December 19, 2011 Try this: <script language="javascript"> function confirmMySubmit(theForm){ if(confirm("Ready?")){ theForm.submit(); } } </script> <form action="http://www.jotorres.com"> <input type ="button" value="Submit" onclick="confirmMySubmit(this.form);"> </form> Link to comment https://forums.phpfreaks.com/topic/253224-php-javascript-confirm-msg-help/#findComment-1299128 Share on other sites More sharing options...
scootstah Posted December 19, 2011 Share Posted December 19, 2011 Try this: <script language="javascript"> function confirmMySubmit(theForm){ if(confirm("Ready?")){ theForm.submit(); } } </script> <form action="http://www.jotorres.com"> <input type ="button" value="Submit" onclick="confirmMySubmit(this.form);"> </form> It should be like this: <form action="" method="post" onsubmit="return confirm('Ready?');"> <input type="submit" value="submit" /> </form> Link to comment https://forums.phpfreaks.com/topic/253224-php-javascript-confirm-msg-help/#findComment-1299134 Share on other sites More sharing options...
jotorres1 Posted December 19, 2011 Share Posted December 19, 2011 I just tested this, and it worked for me. onclick="confirmMySubmit(this.form);" Link to comment https://forums.phpfreaks.com/topic/253224-php-javascript-confirm-msg-help/#findComment-1299135 Share on other sites More sharing options...
scootstah Posted December 19, 2011 Share Posted December 19, 2011 I just tested this, and it worked for me. onclick="confirmMySubmit(this.form);" What if Javascript is disabled? Then the button is going to do nothing. Confirms should be on the onsubmit event. And running it through a function like you did may work, but it can be done a much simpler way. Link to comment https://forums.phpfreaks.com/topic/253224-php-javascript-confirm-msg-help/#findComment-1299138 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.