InterviewSolution
Saved Bookmarks
| 1. |
Explain the new form elements of <datalist> and <output>. |
Answer»
In our example, the <datalist> tag operation is straightforward as, it is used to select a list of browsers. Then there is a <input type=“range”> slider in our code. Once we slide it the value of it is processed and shown in our <output> tag. <!DOCTYPE html> <html> <head> <META charset="utf-8" /> <title>Datalist and output</title> <style> form{ display: grid; place-content: center; grid-gap: 10px; border: 1px solid black; } label { font-family: "FIRA Sans", sans-serif; } </style> </head> <body> <form oninput="ratings.value = parseInt(z1.value)"> <h1>Datalist & Output Demo</h1> <div> <label for="myBrowser">Choose a browser from this list:</label> <input list="browsers" id="myBrowser" NAME="myBrowser" /> <datalist id="browsers"> <option value="Chrome"> <option value="Firefox"> <option value="Internet Explorer"> <option value="Opera"> <option value="Safari"> <option value="Microsoft Edge"> </datalist> </div> <div> <label for="browserRating">Give a Rating for your browser:</label> <input id="browserRating" type="range" name="z1" value="0" /> </div> <div> <label for="myRatings">My Ratings:</label> <output id="myRatings" name="ratings"></output> </div> </form> </body> </html>Selecting the <datalist> On changing the rating |
|