[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

javascript form.reset - make it ignore a control

Posted on 2013-02-06
4
Medium Priority
?
267 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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 1000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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 basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

650 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