Solved

javascript form.reset - make it ignore a control

Posted on 2013-02-06
4
264 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 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

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 …
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

688 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