javascript - Passing a variable to a html modal -


i trying following.

  1. when user clicks on button modal should show up
  2. the modal should show different content depending on button has been pressed
  3. there many buttons of kind on site. want pass variable modal , make if comparison

here modal

<div class="modal fade" id="group_selection" role="dialog">  <div class="modal-dialog">   <div class="modal-content">            <div class="modal-header">               <button type="button" class="close" data-dismiss="modal" aria-label="close"><span aria-hidden="true">&times;</span></button>               <h4 class="modal-title" id="mymodallabel">select journal club vote should count</h4>           </div>            <div class="modal-body">                 <form>                    {% group in groups %}                        <input class="group_sel" type="checkbox" value="{{ group[0] }}">{{ group[0] }}                       </input><br>                    {% endfor %}                </form>           </div>            <div class="modal-footer">               <input class="btn btn-primary multivote" type="submit" data-dismiss="modal" value="select" />               <input class="btn btn-default" type="button" data-dismiss="modal" value="close" />           </div>         <!-- </form>  -->                                   </div> 

the modal above shows selection of groups. selection same each modal, works fine, want disable input statement in loop depending on button has been pressed modal.

i don't know how create new variables within html. hoping jquery can this, trigger modal following jquery command

<script type="text/javascript"> $(document).ready(function(){    $(".vote").click(function(){        $('#group_selection').modal('show');    }); }); </script> 

i know can use jquery write values html code (as shown here passing data bootstrap modal) don't see how can use make if selection?

thanks help

best

carl

simply determine of .vote buttons clicked , perform appropriate task before showing modal, i.e.:

$(".vote").click(function(){        switch($(this).attr('value'))       {           case '5 stars': // assumes button's value '5 stars'             $('#group1').attr('disabled','disabled'); //disables group1 when 5 stars selected                  break;            case '4 stars': ... break;       }       $('#group_selection').modal('show');    }); 

or, assign each different button different .click() handler execute appropriate task.

side notes: should reset disables when modal opened , reset form make fresh each load well


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -