There is a HTML page code:

<form id="form" action="act.html" method="post" target="_blank"> <input type="text" name="txt" value="777"> <input type="submit" value="Отправить"> </form>

As you can see, the form sends the data to the 'act.html' file. Here is the contents of the 'act.html' file:

<span style="color: red;" name="txt"></span>

How to submit this form without using PHP? If this is possible, how much more difficult is it? If you make it easy, then tell me how.

  • I asked this question because my site on which I program does not support the PHP language. And the more so I do not understand a single drop in this language. - nick
  • Is it necessary that the value in the text field appear in the span element? - lampa
  • Here the question is not in sending the data (according to the submission, so the data will be sent), but in their processing. It is impossible to do this without any handler on the backend. (Handler may not be written in php) - RedMonkey
  • @RedMonkey can accept get data. - lampa
  • one
    If done through the server, then here to PHP, Perl, Python, Ruby, ASP.NET, Java, Groovy, node.js. Of these, I only know php =). If to fence curve logic, then it is possible and to make through js on the client. - RedMonkey

2 answers 2

 <form id="form" action="act.html" method="get" target="_blank"> <input type="text" name="txt" value="777"> <input type="submit" value="Отправить"> </form> 

act.html

 <html> <head> <script> function loaddata(){ var tmp = new Array(); // два вспомогательных var tmp2 = new Array(); // массива get = new Array(); var url = location.search; // строка GET запроса if(url != '') { tmp = (url.substr(1)).split('&'); // разделяем переменные for(var i=0; i < tmp.length; i++) { tmp2 = tmp[i].split('='); // массив get будет содержать get[tmp2[0]] = tmp2[1]; // пары ключ(имя переменной)->значение } } //дальше заполняем все, что нам надо данными из массива get document.getElementById("txt").innerHTML = get['txt']; } </script> </head> <body onLoad='loaddata()'> <span style="color: red;" name="txt" id="txt"></span> </body> </html> 
  • I finally made the best of the impossible! xD - nick
  • one
    You did? I doubt it. - Artem
  • Why in doubt? I did it all. - nick

Option 1: we use only GET requests, we receive parameters through JavaScript ( How to retrieve GET parameters from javascript? )

Option 2: we use server programming language. There are actually a lot of them, choose to your taste (PHP, Node.JS, .NET, Java, Python, Perl, Scala ...)

  • And through the GET request, you can do the actions that I asked in the question? - nick
  • Yes you can. Put <form method = "get" ...> On the page act.html write a script that will look at what is transmitted via get and display it on the screen - atom-22
  • Can you tell me how to write this script on the 'act.html' page? It will be good if you do not need to write 10 kg of text there) xD - nick
  • Can. Put method = get in the form. on the next page (act.html), add a function to the onLoad handler for the body tag, which will parse the URI, highlight the parameters and values, and fill out the form. - Magos
  • @Magos, I'm not sure jQuery is there. Could you write full js code? I don’t have a PC at hand, but write code on my phone - something else is a perversion;) - atom-22