Page 1 of 1

A unique problem

Posted: Fri Mar 21, 2003 10:28 am
by phpfreak
dasdf

Posted: Fri Mar 21, 2003 11:50 am
by daven
You need to bounce between pages (or just submit to the same page). Either way, you need to load a page so the php can process, since client-side stuff is handled by javascript. example follows

form.php

Code: Select all

<?php
$state=$_GET['state'];
if($state=="on"){$src="on_button_src";}
else{$src="Off_button_src";}

echo "<img name="button" src="".$src."" onclick="javascript:self.location='process.php?id=".$id."'">

?>
process.php

Code: Select all

<?php
$id=$_GET['id'];
$sql="UPDATE table SET row='on' WHERE id=".$id;
mysql_query($sql,$db_conn);
header("Location: form.php?state=off");
?>