Is there an event handler that I can use to change something in a form *only* after the information typed into the form has been sent out to the server? I don’t want to check for something at the server side, then send something back, because of lag. I tried onsubmit(), but that seems to cause things to happen when the button is clicked, before anything is sent out to the server.
@cgishackJun 28.2008 — #do you mean something like this ?
<i> </i><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script type="text/javascript"> function changeValue() { var name = document.getElementById('username').value; alert("Hello "+ name + ", we are now submitting the form"); }
cgishack: I tried that already. Unfortunately onsubmit() insists on making the changes to the form before the form is submitted, which screws things up.
Declan 1991: Yes, I can do this with Ajax, but Ajax involves waiting for word from the server to say that it has received information before changing the form. This introduces lag, which I don't want. Something that just waited for the data to be on its merry way before doing anything would be best.
@cgishackJun 28.2008 — #So you mean you want a function to fire while the server is processing a request?
This can be done i[B]f you are using Ajax[/B].
If you are not using ajax you can not fire Javascript because the page is reloading at that time and generally JS knows nothing about the previous page.