Jump to content

Need Help On a Comparison Tool (multiple checkbox selection)


bluecorr

Recommended Posts

My knowledge of PHP is limited to making slight changes to existing scripts. I now have the ambition to do a comparison tool as follows.

I want to compare apples, oranges, bananas, grapes and pears. Each option would have a checkbox.

When someone checks apples, oranges and bananas, they'd be taken to static page comp_aob.html, when someone checks apples and bananas, they'd be taken to comp_ab.html.

Could someone help me get started? I'd like this to be as simple as possible but I have no idea where to start.

Thanks!
Assuming you have a page with checkboxes named apples, oranges, etc.just set the action of the form to call a processing page with something like this:

[code]<?php

$compPage = "comp_";
$compPage .= (isset($_POST['apples'])) ? "a" : "";
$compPage .= (isset($_POST['oranges'])) ? "o" : "";
$compPage .= (isset($_POST['bananas'])) ? "b" : "";
$compPage .= (isset($_POST['grapes'])) ? "g" : "";
$compPage .= (isset($_POST['pears'])) ? "p" : "";
$compPage .= ".html";

header("Location: " . $compPage);

?>[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.