I have a set of links which comes from a PHP loop and each link has a onclick()
function which contains a number as the argument.
echo '<a href="#" id="'.$id.'" onclick="openModel('.$id.')">'.$name.'</a>';
So, when the user clicked on the link, I want a jQuery-ui Dialog to popup and display the information relevant to the particular link.
The information is in the DB and they will be queried according to the $id
I', passing in the onclick
function.
This is the code for opening the jQuery dialog
function openModel(id){
var dialog, form;
dialog = jQuery( "#dialog-form-text-box" ).dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true,
buttons: {
"Done": function() {
dialog.dialog( "close" );
}
},
});
form = dialog.find( "form" ).on( "submit", function( event ) {
event.preventDefault();
});
dialog.dialog( "open" );
}
This is the code for what's inside the jQuery dialog
<div id="dialog-form-text-box" title="Text Box">
<p id="mini-title"></p>
<form>
<input type="text" name="textbox-title" id="textbox-title" value="<?php echo $parsedArr[0]['content']['title'] ?>" placeholder="Title"> <br> <br>
<textarea name="textbox-desc" id="textbox-desc" placeholder="Description"><?php echo $parsedArr[4]['content']['content'] ?></textarea>
</form>
</div>
So, what's the way of doing this ?