javascript - 在按钮点击/提交时显示整个表单

标签 javascript html

我已经创建了一个表单。在提交表单时,我想显示整个表单,但目前没有这样做。这是我的代码:

function Openform()
{
    document.getElementById('form1').style.display = '';
}
<div id = "form1" style = "display:none">
<form  id="formirri" method="post" action="" target="_parent">
       <br/><br/>
    <div id="demo">
    <table width="230px" align="center" style="box-shadow: 0px 0px 30px 0px rgba(0, 0, 0, 100);"><tr><td colspan=1></td></tr>
<tr>
    <td><a href="#" class="close-classic"></a></td>
</tr>
</table>

</div>

<input id="dynamic" name="Irrigation Form" type="button" value="Calulation Form" ; onclick = "Openform();"
  style="overflow:hidden;padding: 5px 5px; border-radius: 3px;font-size: 8.5pt; width:200px ; background-color: #E7FCCA; font-weight: bold; ">

最佳答案

你在这里犯的一个错误是你忘记关闭你的 <form>标记,首先使用display:none在您的表单标签中然后使用 onclick()将其样式更改为 display:block .

试试这个

function Openform(){
  document.getElementById('form1').style.display = 'block';
}
  <div style = "Visibility = hidden">
<form  id="form1" method="post" action="" target = "_parent" style="display: none" ><br><br>
    <div id="demo">
      <table width="230px" align="center" style="box-shadow: 0px 0px 30px 0px rgba(0, 0, 0, 100);">
        <tr>
          <td colspan=1>1</td>
        </tr>
        <tr>
          <td><a href="#" class="close-classic">2</a></td>
        </tr>
      </table>

    </div>
</form>

<input id="dynamic" name="Irrigation Form" type="button" value="Calulation Form" ; onclick = "Openform();"
  style="overflow:hidden;padding: 5px 5px; border-radius: 3px;font-size: 8.5pt; width:200px ; background-color: #E7FCCA; font-weight: bold; ">

关于javascript - 在按钮点击/提交时显示整个表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43971859/

相关文章:

javascript - 在闭包中使用 _gaq asynch

在java中从服务器端执行的javascript?

html - 更正 Explorer 的 Flexbox 前缀

javascript - PHP + JS。 onClick 改变颜色并运行 php

Javascript数字格式异常

javascript - 使整个选项卡可点击

javascript - 在 JS-asp.net MVC 中使用@Url.Action

css - 将左列添加到网页 HTML/CSS

javascript - 通过条形码阅读器等外部设备输入输入后选择并突出显示输入

html - CSS 链接类型干扰图像链接