Solved

javascript form.reset - make it ignore a control

Posted on 2013-02-06
4
260 Views
Last Modified: 2013-02-12
I have a form with two cascading dropdowns powered by jquery.  They work well.  The values are populated via jquery after the form loads.

I have a reset button that resets the form to it's original values including blanking out the dropdowns.  I can then re-run my code to populate the dropdowns.  This works, but the dropdowns are first "reset" then set to my values.  This takes a second and doens't look good.

Is there a way to make form.reset ignore these dropdowns and I can handle them myself?
0
Comment
Question by:jackjohnson44
  • 2
4 Comments
 
LVL 1

Expert Comment

by:JamieTownsend
ID: 38860362
Do you have to use form.reset?  Can you not create a method yourself and then clear/reset any controls that you want ?
0
 

Author Comment

by:jackjohnson44
ID: 38860415
I could do that, but this will be used in more areas and that is a lot more work.  If I could just get around this one issue, it would save me hours.

I agree your solution would work, but I am looking to just ignore the dropdowns.
0
 
LVL 1

Accepted Solution

by:
JamieTownsend earned 250 total points
ID: 38860431
I am not so sure about preventing the standard reset from doing drop downs but you can override the reset method using something like

$("#form").bind("reset", function() {

    // potentially loop through all controls apart from drop downs and reset their value ?

    return false;
});
0
 
LVL 53

Assisted Solution

by:COBOLdinosaur
COBOLdinosaur earned 250 total points
ID: 38861323
You could use the onreset event of the form to fire a function that grabs the innerHTML of the controls you want to preserve into a string.  then the repopulation would just be an assignment of the string back to the innerHTML.

Cd&
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now