Beispiel für Xajax Checkboxen deren Zustand bei Klick sofort in der Datenbank hinterlegt werden ohne "submit"
 
         
Rot Ja      
Grün Nein      
Blau Vielleicht      

 
<?php
require ('xajax/xajax_core/xajax.inc.php');
require('detect.php');

$xajax = new xajax();
$xajax->configure('waitCursor', false);
$xajax->configure('defaultMethod', 'GET');

$xajax->register(XAJAX_FUNCTION,"update_color_box");
$xajax->processRequest();
$xajax->configure('javascript URI', 'xajax/');
?>

 
//==============================================================================
// Ajax
function update_color_box($nr, $action){

$link = mysql_connect('localhost', USER, 'PASS');
if (!$link) {
die('Verbindung schlug fehl: ' . mysql_error());
}
mysql_select_db('xajax1', $link);

$nr = substr($nr,1);
$action = substr($action,1);

if( $action=="SET"){
   $result = mysql_query('UPDATE checkbox SET zustand=1 WHERE id='.$nr);
}else{
   $result = mysql_query('UPDATE checkbox SET zustand=0 WHERE id='.$nr);
}

$Response = new xajaxResponse();
return $Response;
}

 
//-------------------------------------------------------------------------------
function check_onoff($id){

$link = mysql_connect('localhost', USER, PASS');
if (!$link) {
die('Verbindung schlug fehl: ' . mysql_error());
}
mysql_select_db('xajax1', $link);
$result = mysql_query('SELECT zustand FROM checkbox WHERE id='.$id);
$row = mysql_fetch_assoc($result);

if( $row['zustand']==1){
   return "checkbox_on.gif";
}else{
   return "checkbox.gif";
}

}

HTML
<a onclick="javascript:flip_checkbox('color_1');" href="#null"><img src="xajax/bilder/<?php echo check_onoff(1);?>" name="color_1" width="15" height="15" border="0" align="absmiddle" id="color_1" /></a>Rot
 
 
Franz Träxler