
- 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 DOM Input Time name Property
The HTML DOM Input Time name property returns a string, which displays the value of the name attribute of input Time. User can also set it to a new string.
Syntax
Following is the syntax −
- Returning string value
inputTimeObject.name
- Setting name attribute to a string value
inputTimeObject.name = ‘String’
Example
Let us see an example of Input Time name property −
<!DOCTYPE html> <html> <head> <title>Input Time name</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>Time-name</legend> <label for="TimeSelect">Appointment at Stephan:</label> <input type="time" name="Stephan" id="TimeSelect" value="18:00"> <input type="button" onclick="changeMeeting()" value="Confirm"> <input type="button" onclick="changeName()" value="Book at Dorcel's"> <div id="divDisplay"></div> </fieldset> </form> <script> var labelDisplay = document.getElementsByTagName("label")[0]; var divDisplay = document.getElementById("divDisplay"); var inputTime = document.getElementById("TimeSelect"); function changeMeeting() { if(inputTime.name === 'Stephan') divDisplay.textContent = 'Stephan Hospital is closed today'; else divDisplay.textContent = 'Appointment at Dorcel Hospital fixed at: '+inputTime.value; } function changeName(){ inputTime.name = 'Dorcel'; labelDisplay.textContent = 'Appointment at '+inputTime.name+': '; } </script> </body> </html>
Output
This will produce the following output −
After clicking ‘Confirm’ button −
After clicking ‘Book at Dorcel’s’ button −
After clicking ‘Confirm’ button with name attribute set to another name −
- Related Articles
- HTML DOM Input Time autofocus Property
- HTML DOM Input Time defaultValue Property
- HTML DOM Input Time disabled Property
- HTML DOM Input Time form Property
- HTML DOM Input Time max Property
- HTML DOM Input Time min Property
- HTML DOM Input Time readOnly Property
- HTML DOM Input Time required Property
- HTML DOM Input Time step Property
- HTML DOM Input Time type Property
- HTML DOM Input Time value Property
- HTML DOM Input Button name Property
- HTML DOM Input FileUpload name Property
- HTML DOM Input Hidden name Property
- HTML DOM Input Month name Property

Advertisements