title: Writing a callback function for a bootstrap modal
body: <p>I have a bootstrap modal confirmation where I want to display the currently selected value of a html select list as well as a value by passing in a variable.</p>
  
  <p>I asked this SO question and received a good answer here about <a href="https://stackoverflow.com/questions/24815921/html-select-list-get-text-value-by-passing-in-a-variable">displaying two values from the same html select list for a JavaScript confirmation popup</a>. However, I now need to replace the JavaScript confirmation with a bootstrap modal.</p>
  
  <p>Here is the html select list:</p>
  
  <pre><code>&lt;select name="language_code" id="id_language_code"&gt;
      &lt;option value="ar"&gt;Arabic - العربية&lt;/option&gt;
      &lt;option value="bg"&gt;Bulgarian - Български&lt;/option&gt;
      &lt;option value="zh-CN"&gt;Chinese (Simplified) - 中文 (简体)‎&lt;/option&gt;
      &lt;option value="en" selected="selected"&gt;English (US)&lt;/option&gt;
      &lt;option value="fr-CA"&gt;French (Canada) - français (Canada)‎&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>I can display two language values on the bootstrap modal, using the following code:</p>
  
  <pre><code>$( "#submit_buttonA" ).attr('update-confirm', 'Are you sure you want to change the language of the website from ' + $('#id_language_code option[value=' + '{{ user.get_profile.language_preference }}' +  ']').text() + ' to ' + $('#id_language_code option:selected').text() + '?');
  </code></pre>
  
  <p>The above code line always returns the 2nd language value <strong>$('#id_language_code option:selected').text()</strong> (which is marked as selected="selected") as <strong>English (US)</strong> on the bootstrap modal, even if the user has selected <strong>Bulgarian - Български</strong>.</p>
  
  <p>I have read up on this and believe that this will require a JavaScript callback function because the bootstrap modal is asynchronous, while the JavaScript confirm() is not asynchronous. </p>
  
  <p>Is this correct? I have tried writing a call back function to return the value of the html select list that the user has selected, but it does not work. I am not sure if this is the correct approach or that my code skills are not good enough.</p>
  
  <p><strong>Can someone show me how to write this call back function and explain how it works, because I am really confused on how to get this to work?</strong></p>