1

I'm using the method already laid out in this thread:

Passing data to a bootstrap modal

It works spot on. I am able to pass data to the modal and display it in a field within a form. The question is: what's the easiest way to use that data in a ColdFusion query within the modal body?

Modal Button:

<a data-toggle="modal" data-id="495.00" title="View Dates" class="open-registerModal btn btn-primary" href="#registerModal">test</a>

Javascript

<script type="text/javascript">
$(document).on("click", ".open-registerModal", function () {
     var myPrice = $(this).data('id');
     $(".modal-body #price").val( myPrice );
});
</script>

Modal Body Query

<cfquery name="getdata" datasource="thedatabase">
   SELECT * 
   FROM Table 
   WHERE cost = (PRICE FROM ABOVE)
</cfquery>

I would really like to use the same modal for all of the buttons on my page and just change out the data-id on each individual button. Any suggestions?

Community
  • 1
  • 1
Big Mike
  • 119
  • 10
  • 1
    @EhsanSajjad "what's the easiest way to use that data in a ColdFusion query within the modal body?" "Any suggestions?" – Big Mike Jun 27 '14 at 19:39

1 Answers1

2

The general idea is to do a POST through ajax. Collect the data you want to post use via .data() and then post to a .cfm or .cfc?method=foo and the values will arrive in the FORM scope or function's arguments in CF respectively.

Henry
  • 32,689
  • 19
  • 120
  • 221