Checked elements creating xml string help
With some help earlier, I was able to make this work when each ID only had one parameter to add to an xml string. Now I'm trying to do it again with 4 parameters to add, without hardcoding each one. Here is the expected format of the XML
<AGREEMENTS>
<AGREEMENT>
//Code will be the checkboxes ID
<CODE>SUBA</CODE>
//I have the versions, but not sure how to add them, possibly this.name?
<VERSION>2.0</VERSION>
//DATETIME will be added by <?php echo $SubmitDATETIME ?>
<DATETIME>4/27/2010 10:28 PM</DATETIME>
//Not sure how to add these, there are multiple 'comment' fields on some, would I give each an
//ID?
<COMMENT>AGREE1=I AGREE|SUBNAMEADDRESS=[whatever customer entered]|OCCUPATION=[whatever customer entered]|EMPLOYER=[whatever customer entered]| TITLE=[whatever customer entered]|EMPFUNCTION=[whatever customer entered]|AGREE2=I AGREE| AGREE3=I AGREE</COMMENT>
</AGREEMENT>
</AGREEMENTS>
Here is what I have that isn't working
function SetAgreements() {
var agreements = '';
$(":checked(#EX_AGREEMENTS)").each(function() {
if("#SUBA:checked").val('<AGREEMENT><CODE>SUBA</CODE><VERSION>2.0</VERSION><DATETIME>' + <?php echo $SubmitDATETIME ?> + '</DATETIME><COMMENT>' + this.classCOMMENTS + '</COMMENT></AGREEMENT>')
});
$('#AGREEMENTS').val('<AGREEMENTS>' + agreements + '</AGREEMENTS>');
}
Is there a way to do this once, and have it work for any checkbox in the fieldset#EX_AGREEMENTS?
Thanks in advance
Kane Leins