用javascript变量填充jquery模态表单字段值

用javascript变量填充jquery模态表单字段值,javascript,jquery,forms,modal-dialog,Javascript,Jquery,Forms,Modal Dialog,我是一个新手,正在尝试在为用户加载时用变量自动填充模式字段值。我有一种预感,加载时需要将.val()添加到对话框中,但不确定。目前,我正在尝试像标准表单一样加载该值。谢谢你在这方面给我的帮助- 按钮以激活模式: <input type="button" id="reply_clicky" name="emailmessage" onClick="updateReplyName('{{email.sender}}')" value="Reply" > $(document).read

我是一个新手,正在尝试在为用户加载时用变量自动填充模式字段值。我有一种预感,加载时需要将.val()添加到对话框中,但不确定。目前,我正在尝试像标准表单一样加载该值。谢谢你在这方面给我的帮助-

按钮以激活模式:

<input type="button" id="reply_clicky" name="emailmessage" onClick="updateReplyName('{{email.sender}}')" value="Reply" >
$(document).ready(function(){ 
    $('#reply_form').dialog({   
        autoOpen: false,
        height: 375,
        width: 350,
        modal: true,
        buttons: [
            {
            text: "Cancel",
            click: function() {
                $(this).dialog("close");
            }},
        {
            text: "Submit",
            click: function() {
                $('#replyemailform').submit();
            }}
        ]
    });
    $('#reply_clicky').button().click(function(e){
        $('#reply_form').dialog('open');
    });


}); 

function updateReplyName(sender){
console.log("updateReplyName function fired");
document.getElementById('recipient').value = sender;
}
$(document).ready(function(){ 
    $('#reply_form').dialog({   
    autoOpen: false,
    height: 375,
    width: 350,
    modal: true,
    buttons: [
        {
        text: "Cancel",
        click: function() {
            $(this).dialog("close");
        }},
    {
        text: "Submit",
        click: function() {
            $('#replyemailform').submit();
        }}
    ]
});


$('#reply_clicky').button().click(function(e){
    $('#reply_form').dialog({
        open: function(e, ui) {
            $('#recipient').val('value is here');
        }
    });
    $('#reply_form').dialog('open');
});
});
编辑以包含DevlshOne的建议:

<input type="button" id="reply_clicky" name="emailmessage" onClick="updateReplyName('{{email.sender}}')" value="Reply" >
$(document).ready(function(){ 
    $('#reply_form').dialog({   
        autoOpen: false,
        height: 375,
        width: 350,
        modal: true,
        buttons: [
            {
            text: "Cancel",
            click: function() {
                $(this).dialog("close");
            }},
        {
            text: "Submit",
            click: function() {
                $('#replyemailform').submit();
            }}
        ]
    });
    $('#reply_clicky').button().click(function(e){
        $('#reply_form').dialog('open');
    });


}); 

function updateReplyName(sender){
console.log("updateReplyName function fired");
document.getElementById('recipient').value = sender;
}
$(document).ready(function(){ 
    $('#reply_form').dialog({   
    autoOpen: false,
    height: 375,
    width: 350,
    modal: true,
    buttons: [
        {
        text: "Cancel",
        click: function() {
            $(this).dialog("close");
        }},
    {
        text: "Submit",
        click: function() {
            $('#replyemailform').submit();
        }}
    ]
});


$('#reply_clicky').button().click(function(e){
    $('#reply_form').dialog({
        open: function(e, ui) {
            $('#recipient').val('value is here');
        }
    });
    $('#reply_form').dialog('open');
});
});

sender
在哪里被赋值?我的想法是将{{email.sender}}传递给updateReplyName函数,并将{email.sender}作为参数…将其命名为“sender”…也许我没有正确地传递该值?只要在打开对话框之前分配了
sender
,您可以使用我在下面发布的答案。感谢您在这方面的帮助,DevlshOne-我添加了您建议的代码,但现在在属性列表后出现语法错误“SyntaxError:missing}”。(见上面编辑的代码)你怎么看-相反,我要感谢……:)