使用预填充字段在jquery对话框中打开HTML页面

时间:2017-06-02 13:29:55

标签: javascript jquery html

我在jQuery ui对话框中打开一个html页面。它只是一个简单的形式,有4个字段。在4个字段中,3个应该预先填充。

所以,我创建了一个这样的表单 -

<!doctype html>
<html lang = "en">
   <head>
      <meta charset = "utf-8">

    <style>
.w3-border-0{border:0!important}.w3-border{border:1px solid #ccc!important}
.w3-border-top{border-top:1px solid #ccc!important}.w3-border-bottom{border-bottom:1px solid #ccc!important}
.w3-border-left{border-left:1px solid #ccc!important}.w3-border-right{border-right:1px solid #ccc!important}
.w3-border-red,.w3-hover-border-red:hover{border-top:1px solid #f44336!important; border-bottom:1px solid #f44336!important ; border-left:1px solid #f44336!important;border-right:1px solid #f44336!important  }
.w3-border-green,.w3-hover-border-green:hover{border-color:#4CAF50!important}
.w3-border-blue,.w3-hover-border-blue:hover{border-color:#2196F3!important}
.w3-border-yellow,.w3-hover-border-yellow:hover{border-color:#ffeb3b!important}
.w3-border-white,.w3-hover-border-white:hover{border-color:#fff!important}
.w3-border-black,.w3-hover-border-black:hover{border-color:#000!important}
.w3-border-grey,.w3-hover-border-grey:hover,.w3-border-gray,.w3-hover-border-gray:hover{border-color:#bbb!important}
.w3-input{padding:8px;display:block;border:none;border-bottom:1px solid #ccc;width:95%}
</style>    
   </head>

   <body>
    <form>
        From<br>
        <input id="senderemailAddresss" type="text" class="w3-input w3-border"  value=""  readonly /><br>
        To<br>
        <input id="receiveremailAddresss" class="w3-input w3-border" type="text"/><br>
        Subject<br>
        <input id="title" class="w3-input w3-border" type="text"/> <br>
        Messgae <br>
        <input id="message" class="w3-input w3-border"  style="height:60px" type="text" rows="4"/>
    </form>

   </body>
</html>

现在,我在像这样的jQuery对话框中打开它 -

var page = "form.html";
               var $dialog = $('<div id="myDialog"></div>')
               .html('<iframe style="border: 0px; " src="' + page + '" width="100%" height="100%"></iframe>')
               .dialog({
                   autoOpen: false,
                   modal: true,
                   height: 485,
                   width: 550,
                   draggable: false,
                   //title: "Send Mail",
                   buttons: { 
                        "Send": 
                        function() 
                        {   scopes.sent = 0;
                            var email = $("#receiveremailAddresss").val();
                            var title = "The Execution Detail for the Rule: "+maintitle
                            var message = $("#message").val();
                            sendEmail(email,title,message,$(this));
                        }, 
                        "Cancel": 
                        function() 
                        { $(this).dialog("close"); }

                        }, 
                   open: function (event, ui) {
                        $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
                     //  $("#title").val(maintitle);
                    $(this).find('#title').val("The title is : "+maintitle);
                    $(this).find('#message').val("Message is :"+ message );
                   $(".ui-dialog-titlebar").hide();
                   $(this).css('overflow', 'auto');
                    $(this).css({
                    'font-size' :'12px'
                    });
                   }
                  });
                 $dialog.dialog('open');

但问题是这些字段没有预先填充。

但是如果我在.html里面做了一个表格 -

.html('<form >From <input id=senderemailAddresss type="text" class="w3-input w3-border" value="'+mailId +'"size="25" readonly><br>To <input id=receiveremailAddresss class="w3-input w3-border" type="text"  size="25"><br>Subject<input id=title class="w3-input w3-border" type="text"> <br>Messgae <textarea id=message class="w3-input w3-border"  style="height:60px type="text" rows="4" cols="20"></form>')          

它正在发挥作用。这里有什么区别,我没有得到?

编辑:因为它被标记为重复,我尝试了复制的解决方案,但在这里它没有提供任何内容。问题是iframe不知道该页面内的内容。它只有它的道路。

0 个答案:

没有答案