mercredi 10 avril 2019

PHP Form Checklist show "For:" label instead of "Value:"

I finally got a checklist working in PHP, but it's listing the "value:" of my input rather than the "for:" the reason I can't use the 'value:' is because the value is a number that gets totalled up and I want to know what option has been ticked instead of just seeing a number,

<input class="basic-config" type="checkbox" name="ch[]" id="basic-option1" value="100"><label for="basic-option1">option 1<span class="right-align">$100</span></label>

<input class="basic-config" type="checkbox" name="ch[]"" id="basic-option2" value="200"><label for="basic-option1">option 2<span class="right-align">$200</span></label>

The PHP is below:

if (isset($_POST['submit'])) {

$name = $_POST ['name'];
$mailFrom = $_POST ['mail'];
$website = $_POST ['website'];
$comments = $_POST ['comments'];
$basicAmount = $_POST ['basic-amount'];
$extras = "None";
if(isset($_POST["ch"]))
$extras = implode(", ", $_POST["ch"]);

$mailTo = "josh@myemail.com";
$headers = "From: ".$mailFrom; 
$txt = "\n
Basic Order Request. \n\n
From: $name \n\n
Email: $mailFrom \n\n
Website: $website \n\n
Comments: $comments \n\n
Extras: $extras \n\n
Total: $basicAmount";
}

How can I get it to list the "for" or even "id" name of the checkbox ticked instead of listing the "value"?

For example, this is what I want:

Extras: Option 1, Option 2 Total: $300

This is what I have at the moment and not what I want:

Extras: 100, 200 Total: $300

Would appreciate any help!




Aucun commentaire:

Enregistrer un commentaire