The current project has the following needs:
First look at the figure ^
Requirements:
1. When you click Export excel, the text box below cannot be modified if you select export or export without pagination.
2. When you click "export by page", the value in the first text box can be modified, but the value in the second text box cannot be manually modified, but it will change with the input value in the first text box.
Implementation:
I will not talk about how to do this page. Let's look at the key points and how to dynamically add attribute values:
Function changeattr () {// onchange event add and remove read-only attributes
VaR radios = Document. Forms [0]. Radio;
For (VAR I = 0; I <radios. length; I ++ ){
If (radios [2]. Checked = true ){
Remattr (); // select the export check box to remove the disabled attribute of the text box.
Break;
} Else {
Addattr ();
Break; // If the selected single-choice button is determined, the loop will jump out.
}
}
}
Function remattr (){
$ ("# Sheet"). ATTR ("disabled", false); // remove the disabled attribute
}
Function addattr (){
$ ("# Sheet"). ATTR ("disabled", true); // Add the disabled attribute
}
Note: sheet here is the ID value in the first text box. Here we use jquery, But what if Javascript is used?
Document. getelementbyid ("sheet"). Disabled = false;