Thanks Jim, works perfectly now. Actually I was trying to combine the
javascript call into the reset button tag that was the problem. Works
perfect now Jim, sorry to have to waste the extra posts. One small
thing had to change was to just add the extra checks for element types
equaling "submit", otherwise my value of the button gotten erased
also. Works like a charm. thanks.

On Friday, April 12, 2002, 12:24:07 PM, Jim wrote:

JC> Hmm.  That smells like the behavior of the browser's reset button
JC> (what you get with <html:reset/>).  Are you *sure* the correct
JC> javascript function is getting called?  If you are, then I'm at a
JC> loss for what could be wrong.  In the immortal words of every
JC> asshole developer out there, "It works for me."  :-)

JC> Rick Reumann <[EMAIL PROTECTED]> writes:

>> Still not working here, although not totally sure why. The javascript
>> works fine for resetting the fields the first time the jsp comes up,
>> but after it is submitted with some errors and the validation errors
>> come back, calling this reset function is not clearing all the fields.
>> It is only clearing fields that are newly typed. Any more insight to
>> why this would be happening?
>> 
>> On Friday, April 12, 2002, 10:59:44 AM, Jim wrote:
>> 
>> JC> I don't think so, Rick.  The javascript effectively mimics a user
>> JC> manually clearing out all the fields on the form.  Once the form
>> JC> is submitted, the new values (empty unless the user put something
>> JC> in after invoking resetForm) will populate the formbean prior to
>> JC> invoking validate.  Upon failing validation, those same values
>> JC> will be presented to the user with the error message, if any.
>> 
>> JC> Try it and see.
>> 
>> JC> -- Jim
>> 
>> JC> Rick Reumann <[EMAIL PROTECTED]> writes:
>> 
>> >> The problem (from what I can gather) using this javascript approach is
>> >> that it really isn't clearing out what is in memory. So for example
>> >> say you call this function and the form clears out but the user types
>> >> in something in the wrong format, when he now submits and gets back
>> >> the validation errors it will also include stuff filled in the form
>> >> that was there before this javascript function was called. I'm pretty
>> >> sure this is what would happen but I could be wrong.
>> >> 
>> >> On Friday, April 12, 2002, 10:09:35 AM, Jim wrote:
>> >> 
>> >> JC> Gross, but effective:
>> >> 
>> >> JC> <script language="JavaScript">
>> >> JC>     <!--
>> >> JC>     function resetForm()
>> >> JC>     {
>> >> JC>       var f = document.forms[0]
>> >> JC>       for (var i=0; i<f.length; ++i) {
>> >> JC>         if (f.elements[i].type != "hidden") {
>> >> JC>           f.elements[i].value = '';
>> >> JC>         }
>> >> JC>       }
>> >> JC>       f.elements[0].focus();
>> >> JC>     }
>> >> JC>     // -->
>> >> JC> </script>
>> >> 
>> >> JC> -- Jim
>> >> 
>> >> JC> Rick Reumann <[EMAIL PROTECTED]> writes:
>> >> 
>> >> >> If the user submits a form and some server side validation is done and
>> >> >> the jsp form returns to the user with some validation, what is the
>> >> >> best way to allow the user to clear the form and start over. Having a
>> >> >> <html:reset> button whill only clear new things they enter, and
>> >> >> refreshing is currently returning the same form with the same
>> >> >> validation errors. I was thinking maybe having a button labeled
>> >> >> "reset" but what it actually does is submit to an action that clears
>> >> >> out all the fields and then returns you? Is this a good way to do it,
>> >> >> or is there a better way with struts?
>> >> >> 
>> >> >> Thanks for any feedback.
>> >> >> 
>> >> >> 
>> >> >> -- 
>> >> >> 
>> >> >> Rick
>> >> >> mailto:[EMAIL PROTECTED]
>> >> >> 
>> >> >> "Why do people in ship mutinies always ask for 'better treatment'? I'd
>> >> >> ask for a pinball machine, because with all that rocking back and
>> >> >> forth you'd probably be able to get a lot of free games." 
>> >> >>   -Jack Handey
>> >> >> 
>> >> >> 
>> >> >> --
>> >> >> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>> >> >> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>> >> 
>> >> 
>> >> 
>> >> -- 
>> >> 
>> >> Rick
>> >> mailto:[EMAIL PROTECTED]
>> >> 
>> >> "The difference between a man and a boy is, a boy wants to grow up to
>> >> be a fireman, but a man wants to grow up to be a giant monster
>> >> fireman." 
>> >>   -Jack Handey
>> >> 
>> >> 
>> >> --
>> >> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>> >> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>> 
>> 
>> 
>> -- 
>> 
>> Rick
>> mailto:[EMAIL PROTECTED]
>> 
>> "There's nothing so tragic as seeing a family pulled apart by
>> something as simple as a pack of wolves." 
>>   -Jack Handey
>> 
>> 
>> --
>> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>



-- 

Rick
mailto:[EMAIL PROTECTED]

"If you're a young Mafia gangster out on your first date, I bet it's
real embarrassing if someone tries to kill you." 
  -Jack Handey


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to