Can an Option in a Select tag carry multiple values?

前端 未结 15 2545
执念已碎
执念已碎 2020-11-22 17:42

I got a select tag with some options in a HTML form:
(the data will be collected and processed using PHP)

Testing:


                    
                    
                    
            
            
    

PHP action (in a file I named doublevalue_action.php)

    ";
            echo "Colour: ". $result_explode[1]."
"; ?>

As you can see in the first piece of code, we're creating a standard HTML select box, with 2 options. Each option has 1 value, which has a separator (in this instance, '|') to split the values (in this case, model and colour).

On the action page, I'm exploding the results into an array, then calling each one. As you can see, I've separated and labelled them so you can see the effect this is causing.

I hope this helps someone :)

提交回复
热议问题