mercredi 28 novembre 2018

Images with PHP and checkboxes

I want to learn how to display combined images with help of checkboxes. Lets say I have three images, the first one is a car, second one is a new wheels for the car, third tinted windows. I always display the original image of the car on the website, but lets say if I click the box for new wheels it appears on the car image or if I click tinted windows box, tinted windows appear on the car. The images are prepared with photoshop and stored in folder, simple stuff.

<form action="#" method="post">
<input type="checkbox" name="option" value="Wheels">Wheels</input>
<input type="checkbox" name="option" value="Tint">Windows</input>
<input type="submit" name="submit" value="Submit"/>
</form>
<?php
if (isset($_POST['option'])){
 // Display.
}
?>

I made a simple form so far and lets say as I said if I check Wheels, the wheels appear on the car, I uncheck it they disappear. Same with Windows. But how can I go about doing that lets say if I had 10 items I would not need to hard code a lot of statements? I am not asking for a code, but just ideas how to do it, because my idea is to hard code many if statements.

Aucun commentaire:

Enregistrer un commentaire