How to set the select to be read-only and not editable and the select value to be passable

How to set the select to be read-only and not editable and the select value to be passable
1. <select style="width:195px" name="role" id="role" onfocus="this.defaultIndex=this.selectedIndex;" onchange="this.selectedIndex=this.defaultIndex;">

This approach makes the drop-down box look the same as usual. The only difference is that after you pull down and select, it won’t respond to you. It’s the same whether you select it or not. It just ignores the customer's choice.

2. Set the disabled attribute <select style="width:195px" name="role" id="role" disabled="disabled">

This looks more direct, and it feels like read-only, and you can’t click or pull down. The words inside will also turn gray.

When the attribute is set to "disabled", the select value cannot be passed when the form is submitted. Remove the disabled attribute before submitting $("#role").removeAttr("disabled");

jquery adds the attribute $("#role").attr("disabled","disabled");

<<:  Nginx reverse proxy learning example tutorial

>>:  Five things a good user experience designer should do well (picture and text)

Recommend

About the processing of adaptive layout (using float and margin negative margin)

Adaptive layout is becoming more and more common i...

An article explains Tomcat's class loading mechanism

Table of contents - Preface - - JVM Class Loader ...

Vue3 gets the current routing address

Correct answer Using useRouter : // router path: ...

jQuery implements font size adjustment case

This article shares the specific code of jQuery t...

How to configure CDN scheduling using Nginx_geo module

Introducing the Geo module of Nginx The geo direc...

Linux redis-Sentinel configuration details

download Download address: https://redis.io/downl...

Complete steps to build a Laravel development environment using Docker

Preface In this article, we will use Docker to bu...

VMWare15 installs Mac OS system (graphic tutorial)

Installation Environment WIN10 VMware Workstation...

Detailed tutorial on how to monitor Nginx/Tomcat/MySQL using Zabbix

Table of contents Zabbix monitors Nginx Zabbix mo...

HTML table tag tutorial (23): row border color attribute BORDERCOLORDARK

In rows, dark border colors can be defined indivi...

Example analysis of the usage of the new json field type in mysql5.7

This article uses an example to illustrate the us...

How to solve the problem that Seata cannot use MySQL 8 version

Possible reasons: The main reason why Seata does ...

JS implements the sample code of decimal conversion to hexadecimal

Preface When we write code, we occasionally encou...