generate functionMon, 27 Feb 2023

onclick of the INPUT TYPE submit field with the ID="convert" start a function that takes the content of the INPUT TYPE text field with the ID="yfullstrht" as a column containing in alternation the variable and a value. Take the input column and write the variables in row 1 and the values in row 2 into a DIV with the ID="ftdnastrht". Additionally print the result to a popup window.

document.getElementById("convert").onclick=function(){ var val = document.getElementById('yfullstrht').value; var valarr = val.split(' '); var valarrlen = valarr.length; var valarrr=valarr.reverse(); var res ="<table>"; for (var i = 0; i < valarrlen; i+=2) { res = res + "<tr><td>" + valarrr[i-1] + "</td><td>" + valarrr[i] + "</td></tr>"; } res = res +"</table>"; document.getElementById("ftdnastrht").innerHTML=res; window.alert(res); }

Generate More

Questions about programming?Chat with your personal AI assistant