jquery check checkbox by id in function
<p>I have a function which the name of a user is passed in and the ID of the checkbox will be that name, I'm trying to get jquery to check it by the ID, but no luck. the ID field of the checkbox is called by each user name so it needs to find the correct checkbox called by the 'name' passed in and check it.</p>

<pre><code>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();       
}
});
}
</code></pre>

<p>HTML (PHP echo's)</p>

<pre><code>&lt;tr&gt;&lt;td&gt;&lt;input class=\'names\' id=\''.$users[$i]['name'].'\' type=\'checkbox\' name=\'names[]\' value=\''.$users[$i]['id'].'\' /&gt;&lt;/td&gt;&lt;td&gt;'.$users[$i]['name'].'&lt;/td&gt;&lt;/tr&gt;
</code></pre>

<p>rendered</p>

<pre><code>&lt;tr&gt;&lt;td&gt;&lt;input class='names' id='dave' type='checkbox' name='names[]' value='3' /&gt;&lt;/td&gt;&lt;td&gt;dave&lt;/td&gt;&lt;/tr&gt;
</code></pre>

<p>does not seem  to work :(</p>

<p>Thanks for any help.</p>
