0

我将从什么代码开始?我知道 onChange 不适用于 input=hidden。最好写一些东西来重命名隐藏字段,然后将其构建到下拉列表的现有 onchange 中?

4

1 回答 1

0

不是 100% 确定你想要做什么。我不相信它可以<input type="hidden"在浏览器上制作带有 show 的标签,除非你改变它的类型。

刚刚在W3Schools测试过这个并在 Chrome 上工作

<input type="hidden" value="OK">

<p id="demo">Click the button below to set the type attribute of the button above.</p>

<button onclick="myFunction()">Try it</button>

<script type="text/javascript">

function myFunction()
{
  document.getElementsByTagName("INPUT")[0].setAttribute("type","button"); 
};

</script>

<p>Internet Explorer 8 and earlier does not support the setAttribute method.</p>

授予此代码显然声明它不适用于 IE8 或更早版本,并且为您想要的每个隐藏字段设置 id 属性可能会更好,并且可能使用类似document.getElementById(IDVALUE).setAttribute("type", "text")虽然这将允许用户更改值标签。

现在剩下的就是提供一个带有 onChange 函数的下拉列表,该函数根据所选内容运行上述语句。

于 2012-06-22T22:23:41.547 回答