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
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>

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.