fill jquery modal form field value with javascript variable -


i newbie - , trying auto fill modal field value variable when loaded user. have hunch need add .val() dialog box when loading, not sure. trying load value standard form. can give me on this-

button activate modal:

<input type="button" id="reply_clicky" name="emailmessage" onclick="updatereplyname('{{email.sender}}')" value="reply" > 

form:

<div id="reply_form" title="send message"> <form id="replyemailform" method="post" action="/sendemailmessage" name="emailposting">      <p>         <label for="recipient">to:</label>         <input type="text"   name="recipient" id="recipient">     </p>     <p>         <label for="subject">subject: </label>         <input type="text"  name="subject" id="subject">     </p>     <p>         <label for="content">message: </label>         <textarea  name="content" id ="content"  class="textarea" rows="4" style=""></textarea>     </p>  </form> </div> 

javascript:

$(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; } 

edit contain devlshone's suggestion:

$(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 here');         }     });     $('#reply_form').dialog('open'); }); }); 

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

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -