Horje
How to use multiple values in HTML Select Option Tag? | HTML Form Code
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 />";
    ?>



Read Full::
HTML Form Code
Category:
HTML Tutorial Code
Sub Category:
HTML Form Code
Uploaded:
2 weeks ago
Uploaded by:
Admin
Views:
14
Tested on:
HTML

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

Single Articles

Share on: