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!

That is indeed easy to do:

<select onchange='clearFields()'>
.... Some other html etc....
<input type='text' id='InputId' maxlength='255' />

And then the javascript:

function clearFields() {
 document.getElementById('InputId').value = "";
}

~G

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.