I am trying to add WordPress wp_dropdown_pages()
to my table as tbody
row via jQuery
. But i get following script error in my firebug
SyntaxError: missing ) after argument list -> label for = "" > Select Page < /label><select name='upr_page[]' id='upr_page[]'
My jQuery
code is
$('#user-manage-table tr:last').after('<tr>< td class = "user-page-class" >< div class = "form-group" >< label for = "" > Select Page < /label><?php wp_dropdown_pages(array("name" => "upr_page[]")); ?>< /div>< /td>< /tr>');
And in view page source window i see following code in jQuery
$('#user-manage-table tr:last').after('<tr><td><div class="form-group"><label>Select User</label><select class="form-control" name="upr_users[]"><option value=2>abc< /option><option value=1>admin< /option><option value=3>def< /option>< /select>< /div>< /td>< td class = "user-page-class" >< div class = "form-group" >< label for = "" > Select Page < /label><select name='upr_page[]' id='upr_page[]'>
<option class="level-0" value="50">Cart</option>
<option class="level-0" value="51">Checkout</option>
<option class="level-0" value="88">Dashboard</option>
<option class="level-0" value="84">Job List</option>
<option class="level-0" value="52">My Account</option>
<option class="level-0" value="82">Post Job</option>
<option class="level-0" value="2">Sample Page</option>
<option class="level-0" value="49">Shop</option>
<option class="level-0" value="90">Transactions</option></select></div></td></tr>');
How can i solve the problem? Thanks in advance.
EDIT
Full JS code
$('#create-new-user-role').click(function (e) {
e.preventDefault();
$('#user-manage-table tr:last').after('<tr><td class = 'user-page-class'>< div class = 'form-group' ><label for = '' > Select Page </label><?php wp_dropdown_pages(array('name' => 'upr_page[]')); ?>< /div>< /td>< /tr>');
});
Try to change single quotes to double in the end of the first line of the last code snippet.
This is not a valid string, so, jQuery expect the closing
)
. You can have one single quotes (the one around the whole string), and use double quotes all around the string (or vice versa) or you should escape the single quotes in the string.