answersLogoWhite

0

After some discussion, here's a simple way to put the question: [ How do you clear all the values in a form? ] The question isn't asking to reset the values; But to clear them. To answer this question, I will show a very simple form that uses JavaScript to clear the two textboxes in a form, when you press a button. ---- <html><head><title>Clearing Forms!</title> <script type='text/javascript'> function clearForm() { document.loginForm.username.value = ""; document.loginForm.password.value = ""; } </script> <body> <form name='loginForm' action='login.php' method='post'> <input type='text' name='username' id='username' value='Type Username' size='20' /> <br /> <input type='password' name='password' id='password' value='Type Password' size='20' /> <br /> <br /> <input type='submit' value='Log in' /> <input type='button' onClick='clearForm()' value='Clear Fields' /> </form> </body> </html> ---- The above HTML + JavaScript outputs two textboxes for user input: One that already says "Type username" and one that says "Type Password". Below them are two buttons; One that submits the information, and another that clears all the information. How does this work? In simple terms, when the normal button is clicked (Not the submit button), the JavaScript function clearForm() (Which is a custom function, created earlier in the <head>) is activated. Whatever clearForm() is said to do, happens. Lets look at what it's actually supposed to do. ---- document.loginForm.username.value = ""; ---- "document" means something's going to change in the output document. "loginForm" is the thing that is changing. "loginForm" is the name of the form the fields are in. "username" is the field that is going to change. "value" is the thing that is going to change in "username". "=" self explanatory. "" means nothing - Null, if you will. That one line of JavaScript will set the username field to empty - Nothing / Null, free to write in again. You should repeat this line as necessary to suit all the input variables you have.

User Avatar

Wiki User

16y ago

What else can I help you with?

Continue Learning about Engineering

How do you get a whole HTML address when you only have part of an HTML?

All HTML addresses have "http://" in front of them and ".[domain]" after them, just type in the missing parts :)


What is the meaning of HTML?

HTML is stand for Hyper Text Markup language. HTML is a skeleton of your website. HTML is a markup language which is very useful for designing a website because without html we can't design a website that's why because html we provide all design pattern for design a website and all browser is only understand HTML format. For more info visit @javatpoint


What is HTML-only?

All websites use HTML, but some sites use HTML in conjunction with one or more other coding languages like Javascript or CSS. HTML-only means it uses just the basic coding.


Can font size be changed in print preview?

There is no print preview in HTML. In HTML, all the changes are reflected in the browser.


What are the last two tags of an HTML document?

The last two tags of an HTML document are the and tags. These tags mark the end of the body and the entire HTML document, respectively. Here's a breakdown of the structure: HTML Use code with caution. Learn more The tag indicates the end of the body content, which is where the visible elements of the web page are placed. It tells the browser that the structural elements of the page have been defined. The tag marks the end of the entire HTML document. It signals to the browser that it has reached the final element of the document and can start rendering the page. Together, these two tags enclose all the HTML content and provide a clear structure for the web page.

Related Questions

Is xHTML the same as HTML strict and what is a HTML frameset declaration?

Yes, XHTML is just the stricter form of HTML. It means that you have to close all the tags that you have opened.


How does HTML code produce forms in a browser?

HTML has predefined functions. The &lt;form&gt; elements binds all the elements within it.


What's the full form of HTML?

HTML is stand for Hyper Text Markup language. HTML is a skeleton of your website. HTML is a markup language which is very useful for designing a website because without html we can't design a website that's why because html we provide all design pattern for design a website and all browser is only understand HTML format. For more info visit @javatpoint


Why xhtml is made?

XHTML is Extensible Hyper Text Markup Language. It is a stricter form of HTML with all tags closed.


What are the values that form the basis of the American way of life?

Freedom and equality


Does Yahoo have HTML format?

Yes, nearly all pages must be in html.


What is meant by method equals post in HTML language?

method="POST" is a common attribute of the HTML &lt;form&gt; tag. What this does is tells the form that it needs to "post" the data to whatever file you have specified in your "action" attribute of the form tag. So your form tag might look something like this: &lt;form action="receive.php" method="POST"&gt;Insert form data here&lt;/form&gt; Again, this will tell the form to post all the data that the user has entered into it to the receive.php file.


What is the function of HTML in a webpage?

The function of HTML as a scripting language is limited to it's design. All the design developed can be viewed by HTML.


What the major problem to create a HTML?

There are no such problems to create HTML pages. All you need to do is create an HTML document and run it on a browser.


How do you get a whole HTML address when you only have part of an HTML?

All HTML addresses have "http://" in front of them and ".[domain]" after them, just type in the missing parts :)


How do you create the registered trademark in HTML?

You use an HTML entity, "&reg;" (without the quotes).See related link for all HTML entities.


Who sets the stardard of HTML uniformity?

HTML standards are set by the World Wide Web Consortium. They've been setting standards for all versions of HTML since HTML 3.2.