Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to pass values arguments to modal.show() function in Bootstrap
    primarykey
    data
    text
    <p>I have a page the shows a list of local cafes. When the user clicks on a certain cafe, a modal dialog is shown, that already has the "cafe name" pre-filled. The page contains many cafe names, and the form should contain the "cafe name" that he clicked on.</p> <p>Following is the list of cafe names generated as text with link button</p> <pre><code> &lt;table class="table table-condensed table-striped"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;B&amp;Js &lt;/td&gt; &lt;td&gt;10690 N De Anza Blvd &lt;/td&gt; &lt;td&gt; &lt;a class="btn btn-primary" data-toggle="modal" onClick="$('#createFormId').modal('show')" &gt;Announce&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;CoHo Cafe &lt;/td&gt; &lt;td&gt;459 Lagunita Dr &lt;/td&gt; &lt;td&gt; &lt;a class="btn btn-primary" data-toggle="modal" onClick="$('#createFormId').modal('show')" &gt;Announce&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Hot Spot Espresso and Cafe &lt;/td&gt; &lt;td&gt;1631 N Capitol Ave &lt;/td&gt; &lt;td&gt; &lt;a class="btn btn-primary" data-toggle="modal" onClick="$('#createFormId').modal('show')" &gt;Announce&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>Here is the modal form</p> <pre><code>&lt;div class="modal hide fade" id="createFormId""&gt; &lt;div class="modal-header"&gt; &lt;a href="#" class="close" data-dismiss="modal"&gt;&amp;times;&lt;/a&gt; &lt;h3&gt;Create Announcement&lt;/h3&gt; &lt;/div&gt; &lt;div class="modal-body"&gt; &lt;form class="form-horizontal" method="POST" commandName="announceBean" action="/announce" &gt; &lt;input type="hidden" name="cafeId" value="104" /&gt; &lt;fieldset&gt; &lt;div class="control-group"&gt; &lt;label class="control-label" for="cafeName"&gt;Where I am Coding&lt;/label&gt; &lt;div class="controls"&gt; &lt;input id="cafeName" name="cafeName" class="input-xlarge disabled" type="text" readonly="readonly" type="text" value="B&amp;amp;Js"/&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="control-group"&gt; &lt;label class="control-label" for="date"&gt;Date&lt;/label&gt; &lt;div class="controls"&gt; &lt;input type="text" class="input-xlarge" id="date" name="date" /&gt; &lt;p class="help-block"&gt;&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="control-group"&gt; &lt;div class="controls"&gt; &lt;input type="submit" class="btn btn-primary" value="create" /&gt; &lt;input type="button" class="btn" value="Cancel" onclick="closeDialog ();" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p></p> <p>Question is how to pass actual value into the "value" attribute of the modal form?</p> <pre><code>&lt;input type="hidden" name="cafeId" value="104" /&gt; </code></pre> <p>The form "show" event is triggered by "onlick" event</p> <pre><code>&lt;a class="btn btn-primary" data-toggle="modal" onClick="$('#createFormId').modal('show')" &gt;Announce&lt;/a&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload