【问题标题】:Readonly css attribute not working只读 css 属性不起作用
【发布时间】:2015-07-13 00:43:36
【问题描述】:

<form action="javascript:goCalc('calcForm')" id="calcForm" name="calcForm">
  <table align="center" border="0" cellpadding="3" cellspacing="1" width="100%">
    <tbody>
      <tr bgcolor="#bfd5ea">
        <td style="font-size: 30px; color: f00; FONT-WEIGHT: bold; TEXT-ALIGN: center">
          Donation:</td>
        <td style="FONT-WEIGHT: bold; TEXT-ALIGN: center">
          Tax Rate %:</td>
        <td style="FONT-WEIGHT: bold; TEXT-ALIGN: center">
          Net Cost of Donation</td>
        <td style="FONT-WEIGHT: bold; color: 00f; TEXT-ALIGN: center">
          Tax Savings</td>
      </tr>
      <tr bgcolor="#e6eef7">
        <td align="middle" nowrap="nowrap" valign="center">
          $
          <input class="formtext" name="inputIncome" size="12">x</td>
        <td align="middle" bgcolor="#e6eef7" nowrap="nowrap" valign="center">
          <select class="formtext" id="inputPercentage" name="inputPercentage">
            <option selected="selected" value="10">10%</option>
            <option value="15">15%</option>
            <option value="25">25%</option>
            <option value="28">28%</option>
            <option value="33">33%</option>
            <option value="35">35%</option>
            <option value="39.6">39.6%</option>
          </select>=</td>
        <td align="middle" valign="center">
          $ <span style="FONT-WEIGHT: bold; TEXT-ALIGN: center"> <input class="formtext" id="inputCost" name="inputCost" readonly="readonly" size="12"> </span>
        </td>
        <td align="middle" valign="center">
          $
          <input class="formtext" id="inputMoney" name="inputMoney" readonly="readonly" size="12">
        </td>
      </tr>
      <tr align="right">
        <td nowrap="nowrap" valign="center">
          &nbsp;</td>
        <td nowrap="nowrap" valign="center">
          <div align="center">
            <input class="btn" name="Submit" type="submit" value="Calculate">
          </div>
        </td>
        <td nowrap="nowrap" valign="center">
          <div align="center">
            &nbsp;</div>
        </td>
        <td nowrap="nowrap" valign="center">
          &nbsp;</td>
      </tr>
    </tbody>
  </table>
</form>

问题是当用户单击计算选项卡时,它不会将其他字段显示为编码...尝试了一切,请帮助 - (2) 只读行问题 - 在代码的下部 - 只需要显示金额的属性

【问题讨论】:

  • 你的goCalc() javascript函数在哪里?
  • 我正在为其构建的站点中有很多这样的内容,但我需要让这个计算器在没有 js(独立运行)的情况下工作,因为我需要添加到我正在构建的移动应用程序中为它...你对我如何让它工作有什么建议,所以当用户输入金额时输出是正确的总数??
  • 感谢您的更新.. 我发现您对缺少 javascript 的看法是正确的...这有很多代码,最后不得不添加其中的一部分..

标签: html css readonly


【解决方案1】:

您是否尝试过在内联 css 上设置 cursor-eventsattribute?说

        #inputMoney{
            cursor-events: none;
        }

或者您也可以尝试使用disabled='disabled' 属性,尽管您必须在提交表单之前启用这些禁用的元素

【讨论】:

  • awwwwwww...现在我感觉很糟糕...对不起:-)这是部分答案..希望这对所有用户都有帮助;对于这个,半复杂的编码...享受**说明(将此代码放在我作为问题发布的代码之后...第 1 部分 >>
  • 第 2 部分>> //取出逗号和美元符号 ** 由 TJ 于 2015 年 7 月 14 日修改 - 已修复正常工作 income=income.replace(/\$/g,'') ;收入=收入.replace(/,/g,''); //计算节省的价值 = Math.round(parseInt(income) * parseInt(percentage)) * 0.01;成本 = Math.round(parseInt(income) * (100-parseInt(percentage))) * 0.01; // 给这两个值一个适当的货币格式,并将其放入表单字段 document.forms[formname].inputMoney.value = outputMoney(savings); document.forms[formname].inputCost.value = outputMoney(cost); // document.forms[formname].inputIncome.value
  • 第 3 部分>> = outputMoney(document.forms[formname].inputIncome.value); } } 函数 outputMoney(number) { return outputDollars(Math.floor(number-0) + '') + outputCents(number - 0); } function outputDollars(number) { if (number.length
  • 第 4 部分>> output+= ',' + number.substring(mod+3*i,mod+3*i+3); } 返回(输出); } } function outputCents(amount) { amount = Math.round( ( (amount) - Math.floor(amount) ) *100); return (amount
  • **如果您要复制和粘贴...请记住,在我发布的每个答案/评论之后,都有一个破折号,然后是我的名字,不要包括破折号;否则代码将无法正常工作:-)
猜你喜欢
  • 1970-01-01
  • 2021-08-06
  • 2014-07-21
  • 2016-08-02
  • 2014-05-22
  • 2012-01-06
  • 2013-11-21
  • 2016-10-11
  • 1970-01-01
相关资源
最近更新 更多