I have a form with two checkbox arrays that I need to pass to a PHP email script. The form data goes through validation with a javascript function before being sent to the PHP script... I am struggling to get the array to into my form data here is one of my checkbox arrays
<div class="choice-group">
<div class="row">
<div class="col-md-4">
<div class="choice">
<input type="checkbox" id="low" name="budgetvar[]" value="low">
<label for="low">Low Cost</label>
</div>
</div>
<div class="col-md-4">
<div class="choice">
<input type="checkbox" id="medium" name="budgetvar[]" value="medium">
<label for="medium">Medium Range</label>
</div>
</div>
<div class="col-md-4">
<div class="choice">
<input type="checkbox" id="premuim" name="budgetvar[]" value="premuim">
<label for="premuim">Premium Range</label>
</div>
</div>
</div>
</div>
And here is my Javascript formData
formData = {
'firstname': $('input[name=firstname]').val(),
'lastname': $('input[name=lastname]').val(),
'phone': $('input[name=phone]').val(),
'email': $('input[name=email]').val(),
'consent': $('input:checkbox[name=consent]').is(':checked'),
'budgetvar': $('input:checkbox[name=budgetvar]').val(),
'optionsvar': $('input:checkbox[name=optionsvar]').val(),
'message': $('textarea[name=message]').val()
};
I then look to get the variables in my PHP script as follows
$budget = implode(', ', $_POST['budgetvar']);
Any help on how to get these values into an array I can then use through a php email would be a massive help! I have looked on here but I can't seem to find anything that I can try and manipulate to fix my problem.. Relatively new to this so complex solutions seem to go over my head a little bit
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire