How to make fff () run from the bottom of the form?

<html> <body> <script type='text/javascript'> function fff() { var x=document.forms["myForm"]["fname"].value; document.write(x); return false; } </script> <form name="myForm" href="" onsubmit="return fff();" > id: <input type="number" value="Текст" name="fname"><br><br> <input type="submit" value="Отправить"> </form> </body> </html> 
  • one
    I am quite sure that in your brain the concept of “being executed from the bottom of the form” is something very simple and clear. But only you. - Igor
  • From the most obvious - place the script below the form?) - ThisMan
  • @Igor, it is assumed that there is some area (empty string, for example) that is on the page below the form. - Olfy
  • @ThisMan This does not work. - Olfy
  • Hmm, well put in this line: <script>fff();</script> - Igor

1 answer 1

call document.write after loading the page, rewrite the whole page

 <html> <body> <script type='text/javascript'> function fff() { var x = document.getElementById("fname").value; //document.write(x); document.getElementById("output").innerText = x; return false; } </script> <form name="myForm" href="" onsubmit="return fff();" > id: <input type="number" value="Текст" name="fname" id="fname"><br><br> <input type="submit" value="Отправить"> </form> <div id="output"></div> </body> </html>