English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Im trying to reset just one form element with javascript?

I have many text boxes, but I am trying to make a "clear field x" button, that wont reset the whole form.
Any ideas?

thanks

2006-09-21 08:12:08 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

Or for a slightly different approach using similar DOM techniques try this:

Step 1: identify your text box with an id



Step 2: add an onclick event to your button onclick="clearit('clearthisbox')"

Step 3: define your function



simple, effective. Click on the button and the function resets the content of the text field in question. Hope this helps.

2006-09-21 10:56:46 · answer #1 · answered by knieveltech 3 · 2 0








You can access any form by using either its name as I did above, or by its index (order of forms) starting with 0 (the first form in a page is forms[0], the second one is forms[1],etc.) The same goes for the form elements. anything that is an tag is an element. If you have multiple elements that share the same name (checkbox groups for example) you will have to reference them by number unless you want to affect a random one from the group.

2006-09-21 15:21:00 · answer #2 · answered by John J 6 · 1 0

fedest.com, questions and answers