Hi folks,
We have buttons in a custom html field on a form. We use these to change the selection in a drop-down field through javascript created from eloquent solutions found here previously. This has been working quite well for the individual instance of the form, but are looking to expand it into a collection with a fixed number of instances. The code, which uses classes, changes every set in the collection (understandably) but would like to restrict the actions to only impacting their respective individual sets.
Tried limiting it with a collection class eg '.Collect01' and '.rpx', then looking into event listeners but not succeeding.
Thinking it may require a function rewrite using '.each' and '.closest' perhaps?
Current single instance form references:
<p><input class="AButt" type="button" value="Item1"> <input class="BButt" type="button" value="Item2"></p>
$(document).ready(function () { function buttStamp() { if ($(this).hasClass('AButt')) { $('.DropMenu select').val("Choice1").change(); } if ($(this).hasClass('BButt')) { $('.DropMenu select').val("Choice2").change(); } } $('.AButt,.BButt,.CButt').click(buttStamp); });
So someone taps 'Item1' button (.AButt) in the html field and it changes the dropdown menu field (.DropMenu) selection to "Choice1", but we only want that for that row/set. Next row might need to be "Choice2" etc.
Would someone have a direction for me please?