Q:

Can I add hidden form fields at submit time?

I'm trying to add an additional hidden form field when submitting a form but can't see it in the POST'ed form data after submission.
$('#myform').submit(function(){        
var hiddenInput = $('<input data-role="none"/>').attr({type:'hidden',name:'myname',value: 'somevalue'});
 $('#myform').appendTo(hiddenInput);
});

The form submits but does not include the hidden field.

A:

Use .append() the way you have written it.
You're trying to append the form to the input with that .appendTo() syntax .

