我的页面上有2个表格。

第一个始终可见,而第二个首先隐藏。

当用户单击指定的单选选项时,将显示第二个表单。

在Chrome和Firefox中,一切都很好,但是在IE中,显示的是表格,但我无法在文本框字段内书写。

最奇怪的是,我可以删除文本框内的所有内容,但不能添加任何内容。

这是一些代码:

第一种形式:

<form name="calendar" action="" method="post">
    <input type="text" name="n" />
    <input type="radio" name="t" value="0" onclick="showSecondForm();" />Option 1
    <input type="radio" name="t" value="1" onclick="showSecondForm();" />Option 2
    <input type="radio" name="t" value="2" onclick="showSecondForm();" />Option 3
    <input type="submit" name="submit" value="Submit" onclick="onSubmitAction();return false;">
</form>


函数showSecondForm()检查是否选中了选项3,如果选中,则显示第二种形式。

第二种形式是:

<div id="customForm" style="display: none;">
    <form name="custom" action="" method="post">
        <input type="text" name="a" />
        <input type="text" name="b" />
        <input type="text" name="c" />
        <input type="text" name="d" />
        <input type="text" name="e" />
    </form>
</div>


这些表格永远不会提交,因为我要做的所有事情都在javascript中,我可以很容易地到达这两种表格。我的所有代码都工作正常,除了在ie中输入文本框。

我的JavaScript

<script type="text/javascript">
    function showSecondForm()
    {
        if(document.calendar.t[2].checked)
        {
            document.getElementById('customForm').style.display = 'block';
        }
        else
        {
            document.getElementById('customForm').style.display = 'none';
        }
    }
</script>

最佳答案

在诸如Google Chorme和Mozilla Firefox之类的浏览器中,当您在文本输入字段上输入maxlenght最大值为0时,文本框长度是“无限”。在Internet Explorer中,它实际上是0,因此您不能在其中编写任何内容。

因此代码必须是:

<div id="customForm" style="display: none;">
    <form name="custom" action="" method="post">
        <input type="text" name="a" maxlength="255" />
        <input type="text" name="b" maxlength="255" />
        <input type="text" name="c" maxlength="255" />
        <input type="text" name="d" maxlength="255" />
        <input type="text" name="e" maxlength="255" />
    </form>
</div>

关于javascript - HTML-我无法在Internet Explorer中的javascript动态显示的某些文本框中编写代码,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7180548/

10-12 00:01
查看更多