Jump to content

PHP Javascript confirm msg help!


freaker87

Recommended Posts

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

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>

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>

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.