I have a form with several inputs. One has a sub-input based on the condition of the original input. An example is:
<input onChange="javascript:addRow()"/>
The JS function works.
function addRow() {
Dynamic HTML code ...
}
However, if the original input is modified a second time, the JS function executes again and adds the dynamic code a second time. I don't want that. If the user needs to change the original input a second time I want to the function to fail to execute on that second or subsequent time.
Does anyone have experience with how to ensure that a JS function is executed only once per page load?
The straightforward methods of using a boolean are not working for me.
function addRow() {
if (alreadyAdded == 'true') {
Dynamic HTML code ...
}}
Thanks in advance.