php - 如何使用 javascript/jquery 将 php 创建的表单中的 "readonly=true"输入字段重置为 "readonly=false"?

标签 php javascript ajax arrays

我有一个从 php 文件创建的表单,以及一个具有只读属性的文本字段,单击编辑按钮(在创建输入字段期间也会创建编辑按钮),我希望该字段为可编辑,我该怎么做?

<td text align="center">
<input type="text" id=SOME_AMOUNT<?= $j; ?> value=<?=" " .$arr[$j]['BILL_AMOUNT'] . "  "; ?> readOnly>
<button type="button" id=EDIT_AMOUNT<?php echo "$j"; ?> class="EDIT_AMOUNT btn btn-mini btn-primary"> Edit Bill</button>

$(document).ready(funcion(){
    $(".EDIT_AMOUNT").click(function(){
        var id=$(this).attr('id');
        var index=id.match(/\d+$/)[0]; // to get the id numerals from the id string
        $("#SOME_AMOUNT"+index).attr("readOnly", false);
    }); 
});

编辑:问题似乎出在 php 文件中包含的用于表格对齐的 JavaScript 中。这怎么可能?

最佳答案

试试这个(纯JS):

document.getElementById('SOME_AMOUNT').readonly = false;

关于php - 如何使用 javascript/jquery 将 php 创建的表单中的 "readonly=true"输入字段重置为 "readonly=false"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17924124/

相关文章:

ajax - Chrome 扩展程序(根据官方教程制作)不起作用

php - 使用 PDO 更改 mysql_ 函数

php - 是否可以在不使用Flash的情况下实现HTML的翻页效果?

javascript - jquery - 我如何访问 dom 中的那些数组和变量?

javascript - Intl.NumberFormat 的指数符号

javascript - 使用 spring 和 thymeleaf 在 post 方法中进行 Ajax 部分刷新

php - Joomla 2.5 分页覆盖

PHP/MySQL 更新查询根本不起作用

javascript - meteor @import css : Resource interpreted as Stylesheet but transferred with MIME type text/html:

php - 值未通过 ajax 将 session 数组更新为 json 数组