2012-05-29 23 views
0

爲了與java腳本中的警報和提示對話框保持一致我在想是否有一個對話框,哪個駕駛室接受2個輸入而不是1個?具有2個輸入的java腳本對話框

我已經嘗試了幾個類似的方法:

創建表單

<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 

無論表單代碼是在HTMLFILE這顯示形式。而不是在形式的形式使用被稱爲

,創造

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

爲了這個,我看到和錯誤未被捕獲的錯誤:NOT_FOUND_ERROR:DOM Exception8

有沒有更好的方法來做到這個 ?

編輯: 後執行一些操作如吉里什以下建議:

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頁面?

+0

這是'document.body.appendChild('newdiv');' – Coder

回答

2

我想你想這種類型的功能,讓您可以檢查此網址

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

而且你喜歡這個,那麼請下載它的代碼,並落實到你的這個代碼.....

+0

謝謝你,但我很遺憾地看到div表單在我已經包含在html代碼中,而不像它出現在對話框中你的網頁。我將在上面的問題中包含錯誤和發現 – bhavs

+0

我意識到上面的鏈接中的代碼示例使用jquery ui插件,我寧願不使用多個插件,因爲我需要的ui非常非常輕,任何對此有何想法? – bhavs