I am trying to set up a "simple" interface using images wiuth rollovers, that when you click them they set a php variable ($section) which determines what "section: the user is in, and sets a few custom images by echoing that $section in theeir image tags. Fpr example, say there are 3 sections: youth, families, and afterschool, and 3 buttons for each. when you click any of the section buttons, a $section is set to equal "youth", "families", or "afterschool".
Is it possible to do this using onClick? Or do I need to have each button be a POST form, using "image" submission? I have tried the latter, but the form does not seem to be submitting, plus I'm not sure how to make the button contain the data for the variable (ie "youth")...I can only set it using a text field. Here is my code:
<?php
if (isset($_POST['submit'])) {
$_POST['section'] = stripslashes($_POST['section']);
$_SESSION['section'] = $_POST['section'];
$section = $_SESSION['section'];
}
else {
$_SESSION['section'] = "NONE";
$section = $_SESSION['section'];
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<!--<input type="text" name="section" maxlength="40">-->
<!--<input name="submit" type="submit" value="youth">-->
<input name="section" type="image" value="youth" src="images/youth.jpg" width="98" height="28" hspace="0" vspace="0" border="0">
</form>
image submit / onClick php variable set help
Moderator: General Moderators