
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML input value Attribute
The HTML input value attribute is used to set/return the value of value attribute.
Let us see an example of Input value property −
Example
<!DOCTYPE html> <html> <head> <title>Input URL value</title> <style> form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } </style> </head> <body> <form> <fieldset> <legend>URL-value</legend> <label for="URLSelect">URL Id: <input type="url" id="URLSelect"> <input type="button" onclick="getUserURL('google')" value="Google"> <input type="button" onclick="getUserURL('bing')" value="Bing"><br> <input type="button" onclick="redirection()" value="Go"> </label> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var inputURL = document.getElementById("URLSelect"); function getUserURL(userName) { if(userName === 'google') inputURL.value = 'https://www.google.com'; else inputURL.value = 'https://www.bing.com'; } function redirection() { if(inputURL.value !== '') divDisplay.textContent = 'Redirecting to '+inputURL.value; else divDisplay.textContent = 'Enter URL'; } </script> </body> </html>
Output
This will produce the following output −
1) Clicking ‘Go’ button with empty url field −
2) After clicking ‘Bing’ button −
3) After clicking ‘Go’ button with url field set −
- Related Articles
- HTML input readonly Attribute
- HTML value Attribute
- HTML value Attribute
- HTML value Attribute
- HTML value Attribute
- HTML option value Attribute
- Change input type value attribute in jQuery
- HTML DOM Input Time value Property
- HTML DOM Input URL value Property
- HTML DOM Input Week value Property
- HTML DOM Input Number value Property
- HTML DOM Input Reset value property
- HTML DOM Input Search value property
- HTML DOM Input Submit value Property
- HTML DOM Input Password value property

Advertisements