Click to See Complete Forum and Search --> : Empty a text field


Qben
02-09-2004, 06:53 AM
I i have a form that looks like this:


<form name="form" method="post" action="page2.php" target="frame2">
<input type="text" name="message">
<input type="text" name="time">
<input type="submit" name="submit" value="Post">
</form>


I want to empty the field "message" on submit.
How do i do that?

TheBearMay
02-09-2004, 07:09 AM
Something like:

form.message.value="";

should work.

Qben
02-09-2004, 07:19 AM
It does empty the field,
but it doesn't send the value that you put before it resets the field..

clairec666
02-09-2004, 07:21 AM
Do you want the form to submit, sending the value that was in the field, THEN reset the field?

Qben
02-09-2004, 07:21 AM
yes

clairec666
02-09-2004, 07:24 AM
So you are working with frames, and the form will submit to the 2nd frame, but you will still see the form in the original frame........... I think this is what you mean :D

So when the form is submitted, you will need to submit the form, and then set a timeout so that another funtion is called, which then resets the field. Does this make sense?

Qben
02-09-2004, 07:26 AM
Yes that correct

clairec666
02-09-2004, 07:31 AM
<form name="form" method="post" action="page2.php" target="frame2">
<input type="text" name="message">
<input type="text" name="time">
<input type="submit" name="submit" value="Post" onclick="submitfunction(); return true">
</form>

<script type="text/javascript">
<!-- Hide from old browsers
function submitfunction() {
form.message.value="";
}
-->
</script>

Qben
02-09-2004, 07:34 AM
thank you