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)
- $(function(c) {
-
- $( "#dialog" ).dialog({
- autoOpen: false,
- width: 260,
- height: 85
- });
- $( "#dialog" ).dialog({
- position: {
- my: 'left, top',
- at: 'right, top',
- of: $('#opener')
- }
- });
- $( "#opener" ).click(function() {
- $( "#dialog" ).dialog( "open" );
- });
- });
-
- $(function(s) {
- $( "#dialog2" ).dialog({
- autoOpen: false,
- maxWidth:300,
- maxHeight: 85,
- width: 300,
- height: 85
- });
- $( "#dialog2" ).dialog({
- position: {
- my: 'left, top',
- at: 'right, top',
- of: $('#opener2')
- }
- });
- $( "#opener2" ).click(function() {
- $( "#dialog2" ).dialog( "open" );
- });
- });
-
-
- <div id="dialog" >Naam<br>
- <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"/> <input type="submit" value="opslaan" > </form>
- </div>
- <button id="opener" border="0" color="white"> <?php echo $row['voornaam'] . " " . $row['achternaam'] ;?> <img src="edit.png" width="10" height="10"></button>
-
- <div id="dialog2" >Geboortedatum<br>
- <p><form method="post" id="leeftijd" > <input type="text" value="" name="geboortedatum" placeholder="<?php echo $row['gebooredatum'];?>" size="11"/> <input type="submit" value="opslaan" > </form>
- </div>
- <button id="opener2" border="0" color="white"> <?php echo $leeftijd ;?> Jaar <img src="edit.png" width="10" height="10"></button>