I currently have a jQuery function which onclick opens a dialog box. This allows a user to reply to a question.
The problem I am having is if there is more than one question the functionality only works on the first button created.
PHP CODE
$C = count($array2);
for($i=0; $i < $C; $i++)
{
echo "<button id='reply'>Reply</button";
}
jQuery
$(function() {
var name = $( "#name" ),
allFields = $( [] ).add( name ),
$( "#form" ).dialog({
autoOpen: false,
height: 200,
width: 700,
modal: true,
buttons: {
Cancel: function() {
$( this ).dialog( "close" );
}
},
close: function() {
allFields.val( "" ).removeClass( "ui-state-error" );
}
});
$( "#reply" ).click(function() {
$( "#form" ).dialog( "open" );
});
});
What I want is on the click on any of these buttons that the dialog box will open allowing the user to reply to a comment.
Thanks in advance.
Dave.
For Reply button, you should use Class instead of Id. Please try these code:
…..
…..