This may be simple, or impossible, but either way, I want to pass a table row name to a modal dialog form via jquery.
$('.activate_modal').click(function(){
var rowid = $(this).attr('name');
$( "#dialog-form" ).dialog( "open" );
});
I am dynamically creating rows via PHP, and on click opens a jquery modal window, I need to pass an id (the var rowid) to the form so it knows what rows is calling the function. is this possible?
You can use jQuery’s
data()method for this.i.e.
And when you need to access the value, you can access it like:
For filling in a form field that appears inside the popup.
var rowid = $(this).attr(‘name’);
$( “#dialog-form” ).data(‘rowID’, rowid); // set the data to be passed
// fill it in here before diaplaying the dialog
// NOTE: if this is the only place you need the rowid on, you dont need to use data() at all
$(‘#yourformfield’).val(rowid);
$( “#dialog-form” ).dialog( “open” );