Solved

javascript form.reset - make it ignore a control

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
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…

734 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