I have a collection that is populated by lookup values. This collection also includes a checkbox that, when checked, should clear one of the values in the collection.
For the purposes of this question, let's say it's a name field and an e-mail field, with a checkbox to clear out the e-mail.
I have some code that works, but it also re-triggers the lookup, so the e-mail value is briefly cleared but then it's immediately populated again:
$(document).ready(function()
{
$('.cf-collection').click( function ()
{
$('.cf-collection > div').each(function ()
{
$(this).find('#q1').click(function()
{
$(this).closest("div").find('#q2 input').val("");
});
});
});
});
I tried adding a second field for e-mail that's not populated by the lookup, defaulting it to the e-mail value using the following calculation, and then clearing it when the box is checked instead of clearing the original e-mail field. The value was cleared, but it was repopulated if another value was added to the collection. It also then contained every e-mail in the collection, not just the one from the same row. Calculation used:
=my_collection.email_field
Ideally, I can figure out how to stop the lookup from re-triggering when JS runs to clear the value. Can anyone assist?
Thank you!