943,169 Members | Top Members by Rank

Ad:
Aug 29th, 2010
0

On change Select option, clear fields

Expand Post »
Hi,

I'm sure this should be easy, but just can't work it out.

I have a select dropdown with several options. The user selects an option and fills out the following few fields. If the user then changes his mind and changes the option in the dropdown, I want all the fields - or just the ones already filled out - to be cleared.

Note: reset() of the form is not an option as there are other things going on (hide/display of fields based on the dropdown option selected).

Any help is much appreciated!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
lewilaloupe is offline Offline
6 posts
since Aug 2010
Aug 30th, 2010
0
Re: On change Select option, clear fields
That is indeed easy to do:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <select onchange='clearFields()'>
  2. .... Some other html etc....
  3. <input type='text' id='InputId' maxlength='255' />

And then the javascript:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. function clearFields() {
  2. document.getElementById('InputId').value = "";
  3. }

~G
Reputation Points: 82
Solved Threads: 74
Posting Pro in Training
Graphix is offline Offline
400 posts
since Aug 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: gps mapping
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Collapse Expand Inside textArea





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC