javascript - 具有 2 个输入的 JavaScript 对话框

标签 javascript html forms

为了与java脚本中的警报和提示对话框保持一致我想知道是否有一个对话框接受2个输入而不是一个?

我尝试了几种方法,例如:

创建表单

<form id="management_form">
Enter Option: <input type="text" id="optiontb" name="option">
<input type="button" onclick="myfunction(this.form)" value="submit"> </form>

并调用

document.management_form.submit(); in the java script method

这会在 html 文件中的表单代码所在的位置显示表单。而不是在调用表单时

并创建

使用的表单

var newdiv = document.createElement();
newdiv.innerHTML = "Entry  <br><input type='text' name='myInputs[]'>";
document.appendChild('newdiv');

为此,我看到错误 Uncaught error:NOT_FOUND_ERROR:DOM Exception8

有更好的方法吗?

编辑: 按照 Girish 的建议执行一些操作后:

html代码如下:

<title>
<style>
 I have include the code for the style
</style>
<script>
 function request()// renamed it here 
   { // this is exactly same the code in the sample web site
      }

我如何调用这个java脚本方法

 function myfunction(frm)
  {
var opt=frm.option.value;  
request();
$( "#dialog-form" ).dialog( "open" ); 

} 这是从

调用的
 <form name="management_form">
  Enter Option: <input type="text" id="optiontb" name="option"> 
 <input type="button" onclick="myfunction(this.form)" value="submit"> </form>

可以在此处添加任何内容,以便将其显示为对话框而不是像 html 页面一样吗?

最佳答案

我认为您想要这种类型的功能,因此您可以检查此 URL

http://jqueryui.com/demos/dialog/modal-form.html

如果您喜欢这个,请下载它的代码并将其实现到您的代码中......

关于javascript - 具有 2 个输入的 JavaScript 对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10794892/

相关文章:

javascript - 如何使用selenium rc查找页面中是否存在javascript错误

php - 传递数据时隐藏的表单字段值不正确

javascript - 如何让我的复选框值和选项值相加并将总和输入到我的文本区域?

html - 将多个 div 与 "align-items"对齐

html - 在 Windows 7 和 8 的 Firefox 上使用 CSS 转换呈现的字体看起来非常粗糙、锯齿状

html - 直接在主体之后的 div 仅在 Firefox 中导致较大的顶部边距

javascript - 通过ajax传递序列化表单和二维数组

jquery - 奇怪的 jQuery 变量传递行为

javascript - 如何根据 React 中同级组件的大小来调整组件的大小?

javascript - 返回空对象的服务函数