I would suggest that you might find it easier to use a library, such as jQuery.
Intercept the submit event on the copied form and ...
1. find the original form - how you find it depends on your HTML
2. find the copied form - it's within the context of #shadowbox_content; exactly how you find it depends on your HTML
3. for each input field - INPUT, SELECT, TEXTAREA - in the copied form, set the corresponding field in the original form
4. close Shadowbox
5. return false (presumably you don't want to actually submit the form!)
Example, using jQuery:
<script type='text/javascript'>
//NB this is an untested, single-form, one-way copy!
function copyBacktoOriginal(){ //context (this) is the submitted copy
var o = $('#someDiv form'); //original form
// for each field on the copy (that does not have the class 'ignoreField'), set the corresponding field on the original...
$(':input:not(.ignoreField)', this).each(function(){
var v = $(this).val() //value of the copy field
, ch = ({radio:1, checkbox:1}[this.type]) //is radio or checkbox
//find target field in original form...
, tgt = this.type=='radio' ? $(':radio[name='+this.name+']', o).filter("[value='"+v+"']") : $(':input[name='+this.name+']', o)
;
// set checked property or value depending on type of field...
if(tgt.length){
if(ch) tgt[0].checked = this.checked;
else tgt.val(v);
}
});
Shadowbox.close();
return false;
}
$(document).ready(function(){
var opts = { onFinish : function(){ $('#shadowbox_content form').bind('submit', copyBackToOriginal); } };
Shadowbox.init(opts);
});
</script>
<div id='someDiv'>
....
<form ...> .... </form>
....
</div>