Multiple Instances of same Modal Form Dialog passing unique data to/through dialog

Multiple Instances of same Modal Form Dialog passing unique data to/through dialog

My page has a list of possible files to download.  The list is generated by user-controlled filters and content of the list will be different each time its created.
The list is in a nice structured table layout where the available files to download are shown with an icon they can click on to get the file.

I am attempting to intercept the process such that when the user clicks on the link, they will instead be diverted to a modal dialog that contains a form for them to supply their name and email.
Once the user name and email are captured, they are sent on their way to the particular file they want.

I am somewhat new to jQuery/jQuery UI and feel like I'm stumbling over something basic about identifying which modal (and therefore which file) is selected.

Any help to get me on the right track would really, really be appreciated.

Here is my code:
  1. <?php
  2.   
  3.    <script type="text/javascript">
  4.   $(document).ready(function() {
  5.      
  6.     $( '#dialog-form' ).dialog({ 
  7.       autoOpen: false,
  8.       height: 450,
  9.       width: 350,
  10.  position: "center center",
  11.  modal: true
  12.     });
  13. $('.create_modal').click(function(){
  14. var dlink = $(this).data('dlink');
  15. $('#DLcatlink').val(dlink);
  16. $('#dialog-form').dialog('open');
  17. return false;
  18. });  
  19. });
  20. </script> 
  21.  
  22. <div id="dialog-form" title="Enter name and email">
  23.   <p>Please enter your name and email before accessing the file download.</p>

  24. <form action="http://www.mydomain.com/next-step" autocomplete="off" method="post" id="neForm">
  25. <label for="DLname">Name</label> <input id="DLname" name="DLname" required type="text"  /> 
  26. <label for="DLemail">Email</label> <input id="DLemail" name="DLemail" type="email" required  />
  27. <input id="DLcatlink" name ="DLcatlink" type="hidden"  value=""> 
  28. <input type="submit" class="btn" value="Submit" />
  29. </form>
  30.    
  31. </div>

  32. /* show a table of available downloads */
  33. /* this code is highly reduced to the main lines concerning the modal dialog */
  34. /* for simplicity, I am showing a simple loop for 10 files */
  35. for (i=0; i<10; i++) {
  36. $download_link = "http://www.mydomain.com/$i";
  37. $download_link_text = '<a href="#" data-dlink="'.$download_link.'" class="create_modal"  title="my title">';
  38. }
  39. ?>