How to put two values into a select HTML form?

How to put two values into a select HTML form?

It’s easy but you need php to process it. You will use explode from PHP.

Let’s say this is your select form.

1
2
3
<select name="categ">
<option value="value1-value2">value1-value2</option>
</select>

You can process it in a php file with:

1
2
3
4
5
6
7
8
9
<?php
 
$post = $_POST['categ'];
 
$categ_explode = explode("-", $post);
 
echo ''.$categ_explode[0].', '.$categ_explode[1].'';
 
?>

Add a comment: