Add option selected disabled in PHP

不问归期 提交于 2020-01-11 06:57:10

问题


I have a form with a dropdown field in PHP with this array:

$field["options"] = array(
     array("value" => "Chişinău", "text" => "Chişinău", "depth" => 0),
     array("value" => "Bălţi", "text" => "Bălţi", "depth" => 0),
     array("value" => "Comrat", "text" => "Comrat", "depth" => 0),
     ...
     array("value" => "Ungheni", "text" => "Ungheni", "depth" => 0)
);

How to add as a first option the <option selected disabled>Choose one</option>?


回答1:


$field["options"] = array(
    array("value" => " ", "text" => "Choose one", "depth" => 0, "selected" => "selected", "disabled" => "disabled"),
    //...rest other option code
);


来源:https://stackoverflow.com/questions/42739380/add-option-selected-disabled-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!