在 PHP 中禁用添加选项 [英] Add option selected disabled in PHP

查看:43
本文介绍了在 PHP 中禁用添加选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 PHP 中有一个带有下拉字段的表单,带有这个数组:

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>?

推荐答案

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

这篇关于在 PHP 中禁用添加选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆