Can you assist me in creating a function to generate element_id-value pairs and saving them into a file with the use of a for loop?
<body>
<form class="box1" >
<fieldset>
<label class="my_text4" >firstelement</label>
<input class="left_padd" type="text" id="firstelement" name="basic_attributes" value="firstvalue" />
<p/>
<label class="my_text4" >secondelement</label>
<input class="left_padd" type="text" id="secondelement" name="basic_attributes" value="secondvalue">
<p/>
<label class="my_text4" >thirdelenent</label>
<select id="thirdelement" name="thirdvalue" >
<option value="option1" selected>option1</option>
<option value="option2">option2</option>
</select>
<p/>
<div> <input class="button1" type="button" id="bt" value="create variable_value file" onclick="saveFile()" /> </div>
</form>
</body>
<script>
let saveFile = () => {
// Extracting data from each form element.
var elements_names = ["basic_attributes"]
for(var j=0; i<elements_names.length; j++)
{
var inputs = document.getElementsByName(elements_names[j])
for(var k=0; i<elements_names.length; k++)
{
var id1 = inputs[0].getAttribute( 'id' );
var value1 = inputs[0].getAttribute( 'value' );
}
//document.write(id1 + " " + value1 + " " + inputs.length)
}
</script>
I need help in creating a function that can iterate through form elements to capture element_id-value pairs.