Remove checkbox value from xml string with click of a separate checkbox
I have a function that builds an xml string from all selected options in a form like this
function SetServices() {
var services = '<SERVICE><SERVICECD>1KNTK</SERVICECD></SERVICE>';
$(":checked:not([name='ServiceType'], #Standard, #NoneForex, #RTT, #PRN, #BW, #Metrics, #STATUS :input, #EX_AGREEMENTS :input, #final_step :input)").each(function() {
services += '<SERVICE><SERVICECD>' + this.id + '</SERVICECD></SERVICE>';
});
$('#SERVICES').val('<SERVICES>' + services + '</SERVICES>');
}
SetServices();
I need to remove 5 checkboxes "#CME1", "#CMEQL", "#CBT1", "#CBTQL", "#NYM1", "#CMX1" from this string if you check the checkbox "#Globex" I tried using a switch case but couldn't get this working.
function SetServices() {
var services = '<SERVICE><SERVICECD>1KNTK</SERVICECD></SERVICE>';
$(":checked:not([name='ServiceType'], #Standard, #NoneForex, #RTT, #PRN, #BW, #Metrics, #STATUS :input, #EX_AGREEMENTS :input, #final_step :input)").each(function() {
if ($("#Globex").is(":checked") )
{
switch ( this.id) {
case "CME1", "CMEQL", "CBT1", "CBTQL", "NYM1", "CMX1":
break;
default:
services += '<SERVICE><SERVICECD>' + this.id + '</SERVICECD></SERVICE>';
break;
}
}
else {
services += '<SERVICE><SERVICECD>' + this.id + '</SERVICECD></SERVICE>';
}
});
$('#SERVICES').val('<SERVICES>' + services + '</SERVICES>');
}
SetServices();
//console.log($("#SERVICES").val());
it pretty much did nothing. I appreciate any help!
Kane Leins