表单提交复选框值

I have a bike
I have a car

I know when the form is submitted the value will be vehicle=Bike&vehicle=Car if both are ticked

Is there a way to make the value to be vehicle=Bike,Car

Put them into one variable then separated in a comma

Since you are using POST and multiple check boxes, set the name of each check box like this:

<input type="checkbox" name="vehicle[]" value="Bike">
<input type="checkbox" name="vehicle[]" value="Car">

Then when your form is submitted you will receive an array of all the checked boxes and their values in the array:

$_POST['vehicle'][];

Now if both boxes are checked you can retrieve the values in a foreach loop:

foreach($_POST['vehicle'] as $type){
   echo "Type = ".$type;
}

With this you will get an output of

Type = Bike
Type = Car

Try this one,

<input type="hidden" name="vechiclesStr" id="vechiclesStr">


//on submitting,
document.getElementById("vechiclesStr").value = document.formname.vechicle.join();