Ms.E
Ms.E

Reputation: 11

window.location.assign doesn't continue

I'm trying to delete a record in my database.

HTML

<a href="" onclick="return delUnit('grams');">DELETE</a>

JS

function delUnit(unit)
    {
    var r=window.confirm("Are you sure you want to delete this unit?");
    if (r==true)
      {
        //window.alert(val); I used alert to see if val was containing the word grams
        window.location.assign("deleteunit.php?val="+unit);
        return false;
      }
    }

PHP

$val = $_GET['val'];
mysql_query("DELETE FROM setuptb WHERE val='$val' AND category='UNIT'");

Upvotes: 1

Views: 199

Answers (1)

Omar Faruque Sohag
Omar Faruque Sohag

Reputation: 533

After window.location.assign() please add return false; like this

window.location.assign("deleteunit.php?val="+unit);
return false;

Upvotes: 2

Related Questions