I have a problem, I created a builder for form, the user adds several fields and I would like in JavaScript to be able to modify the id and make it unique for the data recovery.
In my function I did this but the id is modified only for the first field...:
let id = () => {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
}
document.getElementById("changeInput").id = "changeInput" + id();
I have this:
<input class="build-element" id="changeInput" placeholder="Some text" value=""/>
<input class="build-element" id="changeInput" placeholder="Some text" value=""/>
<input class="build-element" id="changeInput" placeholder="Some text" value=""/>
and I would like to have for example something like this:
<input class="build-element" id="changeInput1" placeholder="Some text" value=""/>
<input class="build-element" id="changeInput2" placeholder="Some text" value=""/>
<input class="build-element" id="changeInput3" placeholder="Some text" value=""/>