Skip to content

Latest commit

 

History

History
42 lines (37 loc) · 1.02 KB

ex_46.md

File metadata and controls

42 lines (37 loc) · 1.02 KB

Exercise 46

  • Create the following folder/file structure:
/ex_46
  |-- index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Form Properties</title>
</head>
<body>
  <form action="save_usuario.html" method="post" enctype="application/x-www-form-urlencoded" name="login">
    <select id="countries">
      <option value="1">Argentina</option>
      <option value="2">Brazil</option>
      <option value="3">Canada</option>
      <option value="4">Colombia</option>
    </select>
    <input type="submit" name="submit" value="Submit" />
  </form>
</body>
</html>

index.html

  • Create a basic HTML document
  • Create a script tag on the document head element
  • Select the form element using any of the JavaScript selectors
  • Add a submit event handler to prevent the default form behaviour
  • Show the following message when the user submits the form:
%selectedCountry% has been selected and it has %optionValue% as id

Tip

  • Remember you can get an element innerText to get the content