Is there a way to update php-variables that are sent to a javscript function with a onClick-event without updating the whole session?
When you click the button I want to send a new query to the datebase and check the updated database value, where $status['kon'] is the database value I want to get.
PHP Code:
<td width="15%" align="right"><img src="images/arrow-r-icon.jpg" alt="" width="18" height="20" id="<?=$subdepartment[$a]['id']?>konsub_<?=$a?>" class="imgover" onClick="konavdh('<?=$subdepartment[$a]['id']?>kon','<?=$subdepartment[$a]['id']?>','<?=$status['kon']?>','<?=$subdepartment[$a]['kon']?>','<?=$menu[$j]['name']?>');"/></td>
The js-function:
Code:
function konavdh(id,depid,type,subid,subname)
{
var konet=$('#'+id).val();
if(kontyp[id]=='M/K')
{
konet='M';
}
if(kontyp[id]=='K')
{
konet='M/K';
}
if(kontyp[id]=='M')
{
konet='K';
}
}
else {*/
if(type=='')
{
konet='M';
}
if(type=='M/K')
{
konet='M';
}
if(type=='K')
{
konet='M/K';
}
if(type=='M')
{
konet='K';
}
$('#'+id).val(konet);
$('#'+id+'value').html($('#'+id).val());
autoSave(depid);
$.modal.close();
/* });
}
});*/
}
The idea is to get a updated value of $status[0] (var type in javascript) everytime the onClick-event is triggered. The autoSave(depid) function updates the database with the variable "konet".
One way could be to start a php-function at the same time as the onClick-event:
PHP Code:
function updateDb(depid)
{
$depart=$_POST['depid'];
$sqlgen="select kon from chk_subdepartment where id='".$depid."'";
$sqlgenupdate=mysql_query($sqlgen);
$rowgen=mysql_fetch_row($sqlgenupdate);
return $status[0]=$rowgen[0];
}
Unfortunately that don't work because php is executes on the server...
Is there a way to send the updated database value to the javascript function?