I am failing to pass arguments to the calling function.
Specifically, I have a table where when I click on the title I have to open a form where the value of the arguments passed must be copied into the various fields of it. To do this, I call through href (as you can see from the code) the function with the parameters passed.
I get the following error:
Uncaught SyntaxError: missing ) after argument list
Object.entries(results).forEach(item => {
item = item[1];
let child = document.createElement("tr");
child.innerHTML = `
<td>${item.number}</td>
<td><a href="javascript:showFrag(${item.id},${item.number},${item.type});">${item.type}</a></td>`;
document.querySelector('#my-table').appendChild(child);
})
function showFrag(id, number, type) {
return id, number, type;
}
function onLoad() {
showFrag(id, number, type);
var id = document.getElementById('id');
var number = document.getElementById('number');
var type = document.getElementById('type');
id.value = id;
numbr.value = number;
type.value = type;
}
onLoad();
<div class="split left">
<div class="centered">
<table id="my-table" width="90%">
<tr>
<th>Number</th>
<th>Type</th>
</tr>
</table>
<br><br>
</div>
</div>
<div class="split right">
<div class="centered"> <br>
<div class="container">
<form method="post" id="save" action="javascript:myFunction()" onload="onLoad()">
<div class="field">
<label for="id">ID :</label>
<input type="number" id="id" name="id" />
</div>
<div class="field">
<label for="number">Number:</label>
<input type="number" id="number" name="number" />
</div>
<div class="field">
<label for="type">Type:</label>
<select name="type" id="type" form="typeform">
<option value="Title">Title</option>
<option value="Text">Text</option>
<option value="Video">Video</option>
</select>
</div>
<div class="button">
<button type="submit" class="full">Save modifiche</button>
</div>
</form>
</div>
</div>
</div>
myFunction() is not present because it has yet to be done, I am only interested in passing for now the value of the parameters passed in the various fields of the form .