开发者

HTML Form onSubmit()

My HTML form is clearing开发者_运维问答 automatically after I click the submit button. Any idea how to stop this from happening?

Here's the opening tag for the form:

<form onsubmit="return math()">


One popular approach is to utilize a server-side language such as PHP which reads all the get values and recreates the HTML of the page using a template and substituting in variables.

<input type = "text" name = "Textbox1" id = "Textbox1" value = "{$_GET[Textbox1]}"/>

I've written it out as $_GET directly, but you'd really want to make sure the value was scrubbed so you don't get arbitrary html injection.

A little bit more complicated you could approach this purely client side and utilize javascript to parse the address bar and extract the values submitted to your page (assuming it wasn't submitted with POST as the method). Then you can dynamically repopulate the fields client side.


when you click submit the page refreshes. You'll probably need to return a page with the value of the forms set to what was in when it was submitted.


If math() returns false your data won't disappear but it won't sent data to the server either. If you want to send data to the server you could make a XMLHttpRequest.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜