JQUERY dialog with different possible forms.

JQUERY dialog with different possible forms.

Hey All,

First of all very new to jquery so sorry if this is a stupid question. I have a page which gets data from a database and loads it into a div on my index page. 

Within this page i have information about a certain user. (Name, Age etcetc) This information is outputted as a button which opens a dialog when clicked upon. Within this dialog i have a form. As things stand everything works perfectly but i have a lot of code because every form has its own dialog function. Is there a way to combine my code to get it into one single function? (while achieving the same result)

For instance i have these 2 dialogs (got many more but to keep things tidy i only show 2)

  1. $(function(c) {
  2.     $( "#dialog" ).dialog({
  3.       autoOpen: false,
  4.         width: 260,
  5.         height: 85
  6.     });
  7. $( "#dialog" ).dialog({
  8. position: { 
  9. my: 'left, top',
  10. at: 'right, top',
  11. of: $('#opener')
  12. }
  13.  });
  14.     $( "#opener" ).click(function() {
  15.       $( "#dialog" ).dialog( "open" );  
  16.     });
  17. });
  18. $(function(s) {
  19. $( "#dialog2" ).dialog({
  20. autoOpen: false,
  21. maxWidth:300,
  22. maxHeight: 85,
  23. width: 300,
  24.         height: 85
  25.     });
  26. $( "#dialog2" ).dialog({
  27. position: { 
  28. my: 'left, top',
  29. at: 'right, top',
  30. of: $('#opener2')
  31. }
  32.   });
  33.     $( "#opener2" ).click(function() {
  34.       $( "#dialog2" ).dialog( "open" );
  35.     });
  36. });


  37. <div  id="dialog" >Naam<br>
  38. <p><form method="post"  id="naam"> <input type="text" value="<?php echo $row['voornaam'];?>" name="voornaam"  size="8"/> <input type="text" value="<?php echo $row['achternaam'];?>" name="achternaam"  size="8"/>&nbsp;<input type="submit" value="opslaan" > </form> 
  39. </div>
  40. <button id="opener" border="0" color="white"> <?php echo $row['voornaam'] . " " . $row['achternaam']  ;?> &nbsp; <img src="edit.png" width="10" height="10"></button>

  41. <div id="dialog2" >Geboortedatum<br>
  42. <p><form method="post" id="leeftijd" > <input type="text" value="" name="geboortedatum" placeholder="<?php echo $row['gebooredatum'];?>" size="11"/> &nbsp;<input type="submit" value="opslaan" > </form> 
  43. </div>
  44. <button id="opener2" border="0" color="white"> <?php echo $leeftijd   ;?>&nbsp; Jaar &nbsp; <img src="edit.png" width="10" height="10"></button>