Html Form Output As A Table
I have developed the HTML form, which pretty much looks as below: Afterwards, I've prepared an external html file, where this form output is located. I've followed the tutorial be
Solution 1:
The proper HTML table structure is required at the very beginning.
<tableid="opresults"class="outputtable"><pclass="outputtablehead">Survey Form - output</p><trclass="colname"><th>Form question</th><thcolspan="2">Answer</th></tr></table>
and next in our javascript code we should split the append
attribute between the name
and value
separately, placing the table attributes between them
<script>const resultsList = document.getElementById('opresults')
const matches = document.querySelectorAll("fieldset");
newURLSearchParams(window.location.search).forEach((value, name) => {
resultsList.append(document.createElement('tbody'))
resultsList.append(`${name}`)
resultsList.append(document.createElement('td'))
resultsList.append(`${value}`)
resultsList.append(document.createElement('br'))
})
</script>
A quite good solution was here:
Post a Comment for "Html Form Output As A Table"