Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reset Button and onblur events

Status
Not open for further replies.

jl8789

MIS
May 22, 2003
293
US
I have a generic reset button on my form what resets all the values in the text boxes back to the original values that were in there when coming in to the page. On those text boxes I have an onblur event that changes the color of the text if the user goes in and changes the value from it's original value. If the user enters what was the original value in the text box, it changes or keeps the color of the text black or default color. The function works fine when the user is changing the text values, BUT, how come when I use the reset button and it changes all the changed values back to the orginal values, the onblur event behind the text controls must not be called because the colors of the text is not changed back to the original or black text like it does in the function when the user changes the values. Why is this? How can I get the onblur functions to be called? I don't want to have to write an entire reset function and try to keep track of all the original values etc on the form. The form is a calendar and obviously changes month to month, and each day can have up to 3 different text values on it.

THANKS for helping me understand!
 
You can put an event handler onreset on your form that you are resetting i.e.

Code:
<form id="blah" onreset="function()">

From there just make everything your default color inside the function


<.
 
The form's Reset() method resets the values of all elements in a form, it does not affect element formatting. For that, you would have to have a reset function to return your form element formats.

HTH,
Larry
 
I get a "stack overflow at line 0" when trying to do that formReset function... I'm pretty sure I'd have to reset each day's text controls and know what the default values were. Cuz when I use my function that is behind my onblur it sends in the text object and the original number that was in that field. If it equals the original it sets the color to black, otherwise changes it to purple signifying that it was changed... Maybe I can build the reset function as I build my form somehow and then call it behind onreset function on the form?
 
On the onreset event handler, you would not have to know what the default values are cause after clicking your form's reset button, the defaults get displayed. Therefore you would just have to go through every element that can have a color change and if it's not the default color, make it the default color.

About that stack overflow, you must have functions calling functions without returning from any.

<.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top