I have a function in which the username is passed, and the checkbox identifier is the name, I'm trying to get jquery to check it by identifier, but no luck. the checkbox identifier field is called by each username, so he needs to find the correct checkbox called "name" and check it.
function send_new_message(name) { var html = new_message_form(); var div = $(html); //Set user clicked to checked //$("#dave").prop("checked", true); $("#" + name).prop('checked', true); div.find('.send').click(function() { //Remove any error message $("p.error").html(''); //Error check var name = $("input.name").val(); var message = $("#message").val(); if(message==""){ $(".error").html('This filed is required!'); $("#message").focus(); return false; } //Send message to be processed var post_data = name + "##@##" + message; $.post( 'frames/process_messages.php', {name: name, message: message}, function(result){ alert(result); } ); //Close //div.dialog('close'); }); div.dialog( { title:"Send New Message", width: 450, show: { effect: "fold", duration: 500 }, hide: { effect: "explode", duration: 500 }, close: function(){ $(this).dialog("destroy"); $(this).remove(); } }); }
HTML (PHP echo's)
<tr><td><input class=\'names\' id=\''.$users[$i]['name'].'\' type=\'checkbox\' name=\'names[]\' value=\''.$users[$i]['id'].'\' /></td><td>'.$users[$i]['name'].'</td></tr>
it turns out
<tr><td><input class='names' id='dave' type='checkbox' name='names[]' value='3' /></td><td>dave</td></tr>
doesn't seem to work :(
Thanks for any help.
source share