2
I can use the same name="" in two checkbox inputs to do a PHP validation?
For example, I want to take the checkbox value checked and do a validation, but it’s not getting any value.
<input id="add-festa-k" onclick="marcaDesmarcaFesta(this)" class="tfesta" type="checkbox" name="tipoFesta" value="1499" />
<label for="add-festa-k">Festa 1</label>
<input id="add-festa-k" onclick="marcaDesmarcaFesta(this)" class="tfesta" type="checkbox" name="tipoFesta" value="2000" />
<label for="add-festa-k">Festa 2</label>
<?php
$tipoFesta = $_POST['tipoFesta'];
if($tipoFesta >= 2000){
$tipoFesta = 'Festa 2';
}else{
$tipoFesta = 'Festa 1';
}
?>
I just posted a piece of code, and yes I am using form and method= post. I cannot use radio due to functions of my application...
– Jvs Corrêa
I get it, but you can use the checkbox normally, I don’t see problems, but what’s your goal for example, if the user clicks on both parties and gives a Ubmit? Just so you understand.
– brnTwp
When the user fills in all fields, I need to take the checkbox value and make a comparison, if the checkbox marked has value="2000" then what will be written in the email will be Party 2
– Jvs Corrêa
I understood, I changed the code, as the alternative is an array, I joined my code with @Diego’s. See if this is how I wanted it.
– brnTwp