Hidden field keeps adding value
I have created a form that builds an Estimate for Books. I have a field hidden depending on a previous field selection, the problem is the SKU for the hidden field keeps getting listed along with the SKU of the shown field.
Can anyone help with a solution to this? Here is the code for the 2 fields, only one of those fields is shown on the form at any one time....
if(input.Container_Pref6 != "None")
{
sku = "6MB";
}
else
{
sku = "6MT";
}
getitemsd = zoho.invoice.getRecords("Items",orgid,"Status.All",sku);
items = getitemsd.get("items").toJSONList();
for each val in items
{
if(val.getJSON("sku") == "6MB" || val.getJSON("sku") == "6MT")
{
itemdetail = Map();
itemdetail.put("item_id",val.getJSON("item_id"));
itemdetail.put("quantity","1");
itemlist.add(itemdetail);
}
}
if(input.Container_Pref12 != "None")
{
sku = "12MB";
}
else
{
sku = "12MT";
}
getitemsd = zoho.invoice.getRecords("Items",orgid,"Status.All",sku);
items = getitemsd.get("items").toJSONList();
for each val in items
{
if(val.getJSON("sku") == "12MB" || val.getJSON("sku") == "12MT")
{
itemdetail = Map();
itemdetail.put("item_id",val.getJSON("item_id"));
itemdetail.put("quantity","1");
itemlist.add(itemdetail);
}
}