0

I have a simple message page where people can react on a specific message. The code:

    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
    $(function () {
    $('form').on('submit', function (e) {
      $.ajax({
        type: 'post',
        url: 'save_comment.cfm',
        data: $('form').serialize(),
        success: function () {
          alert('form was submitted');
        }
      });
      e.preventDefault();
    });
    });
    </script>

    <cfquery datasource="#ns#" name="getdata">
     select text, timeline_id
     from timeline
     order by t_datum desc
     </cfquery>

     <cfoutput query="getdata">
     <p>#text#</p>
     <cfform>
     <cfinput type="hidden" value="#timeline_id#" name="#timeline_id#">
     <cfinput type="text" name="comment"><input type="submit">
     </cfform>
     </cfoutput>

Now the problem is that the form is dynamic. So if I submit some comment the value of the hidden form field timeline_id is i.e. 3,4,5,7. Normaly I could send the value like this:

     <cfform action="save_comment.cfm?timeline_id=4>

but the form is submit with query, so without a page reload.

Any idea's on this?

Thanks!

4

2 に答える 2