[jQuery] blockui form not setting values?
I am using jquery with blockui, and I have a website which you click a
button, it uses blockui to show a small form which you fill out, then
click "submit" to submit the form. However, it's returning "undefined"
for all values of the form.
Here's what the relevant part of my HTML looks like:
<div id='NewUser' style="display:none; cursor: default">
<table>
<tr>
<td>Username:</td><td><input name=username id=username type="text"/></
td>
</tr>
<tr>
<td>Email:</td> <td><input id=email type="text"/></td>
</tr>
</table>
<input type="button" id="save" value="Save" />
<input type="button" id="cancel" value="Cancel" />
</div>
Here's my jquery code: (#test) is the button to bring up the div,
dcontent is the selector for the div.
// cache the question element
var dcontent = $('#NewUser')[0];
$('#test').click(function() {
$.blockUI(dcontent, { width: '275px' });
});
$('#save').click(function() {
// update the block message
$.blockUI("<h1>Saving...</h1>" );
alert($("#username").value);
$.post(
"saveNewUser", // name of function to call
{
...
}
,function() {$.unblockUI();}
);
});
I've tried using .value and .val() - both return "undefined".