Horje
How to use multiple values in HTML Select Option Tag?

I achieved it by using the PHP explode function, like this:


Step-1: HTML Form in a file I named doublevalue.php

Follow the Example.
index.html
Example: HTML
    <form name="car_form" method="post" action="doublevalue_action.php">
            <select name="car" id="car">
                    <option value="">Select Car</option>
                    <option value="BMW|Red">Red BMW</option>
                    <option value="Mercedes|Black">Black Mercedes</option>
            </select>
            <input type="submit" name="submit" id="submit" value="submit">
    </form>

Step-2: PHP action in a file I named index.php

Follow the Example.
doublevalue.php
Example: PHP
    <?php
            $result = $_POST['car'];
            $result_explode = explode('|', $result);
            echo "Model: ". $result_explode[0]."<br />";
            echo "Colour: ". $result_explode[1]."<br />";
    ?>





Related Articles
How to crearte HTML textarea auto expand height HTML Form Tutorial
How to use multiple values in HTML Select Option Tag? HTML Form Tutorial


Read Full:
HTML Form Tutorial
Category:
Web Tutorial
Sub Category:
HTML Form Tutorial
Uploaded:
3 months ago
Uploaded by:
Admin
Views:
10
Tested on:
HTML
Ref on:
View



Share on: