i want to delete php session variable using a key press. so i used these codes,
<script type="text/javascript">
function textsizer(e){
var evtobj=window.event? event : e
var unicode=evtobj.charCode? evtobj.charCode : evtobj.keyCode
var actualkey=String.fromCharCode(unicode)
if(actualkey=="x"){
location.href="biling.php?cmd="+actualkey;}
}
document.onkeypress=textsizer
</script>
<?php if(isset($_GET['cmd'])){
unset($_SESSION["bill_array"]);
header('location:biling.php');
}
?> }
but the problem is, this code also clearing the session when i’m typing “x” in a text box. so i just want to stop that and clear the session only when i press “x” out side of a text box
I think you can edit your existing function as such: