To solve the problem that jquery does not pass a value to the disabled attribute, jquerydisabled

Source: Internet
Author: User

To solve the problem that jquery does not pass a value to the disabled attribute, jquerydisabled

Question: After an uneditable judgment is added to the review page, click review. An error is reported, and the data in the form is not passed.

The following is the code added to js to determine whether it is on the review page. Remove the code and click the [review] button to transfer data normally. If it is added, it cannot be passed.
    if (data.WF_W_STATUS > 0 && data.WF_W_STATUS != 2) {                $('input,textarea').attr("disabled", "disabled");            }
Details:

In the form, if you add attributes such as disabled = "disabled" or disabled = "true" to the input, the value is not transferred to the background when the form is submitted.

Cause: If the disable attribute is added to an element on the HTML page, this element is only displayed to the user. When the form is submitted, this element is not submitted to the background for processing. therefore, when an element is added with the disabled attribute, the value of this attribute cannot be obtained in the background.

Solution: Write another hidden attribute, one for display, and the other for passing values.

Processing Method:

1. First remove the input in js and change it to: input [type = text]. This is only used to hide the types of text and textarea,

 
(data.WF_W_STATUS > 0 && data.WF_W_STATUS != 2) {                $(':input[type=text],textarea').attr("disabled", "disabled");            }

Add hidden fields to the submitted form.

    <input type="hidden" id="XSBH" name="XSBH" />    <input type="hidden" id="WORKFLOWID" name="WORKFLOWID" />    <input type="hidden" id="WF_W_STATUS" name="WF_W_STATUS" />    <input type="hidden" id="WF_T_NODENAME" name="WF_T_NODENAME" />    <input type="hidden" id="WF_T_AUDITNAME" name="WF_T_AUDITNAME" />    <input type="hidden" id="WF_T_AUDITSTATE" name="WF_T_AUDITSTATE" />

  

Put it in a form and make the form submit a hidden type when submitting the form. However, you must note that if you load the value before and after disabled, it will overwrite it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.