Skip to content
Related Articles

Related Articles

Improve Article

How to specify the value to be sent to a server ?

  • Last Updated : 26 Mar, 2021

In this article, we will see how to specify the value of an option so that this value is sent to the server.

The value attribute can be used for this purpose. It specifies the value to be sent to a server in the <option> element. The content between the opening and closing tags of <option> will be displayed by the browser in the drop-down list. However, the value that was defined in the value attribute is what will be sent to the server when the form is submitted.

Syntax:

<option value="value">

Example:

HTML




<html>
<body>
  <h1 style="color: green">
    GeeksforGeeks
  </h1>
  <h3>
    Select an option to see its 
    value being sent to the server
  </h3>
  <form action="form.php">
    <label for="Subject">
      Subject:
    </label>
    <select id="subject" name="subject">
      <option value="phy">
        PHYSICS
      </option>
      <option value="chem">
        CHEMISTRY
      </option>
      <option value="bio">
        BIOLOGY
      </option>
      <option value="math">
        MATHEMATICS
      </option>
    </select>
    <input type="submit" value="Submit">
  </form>
</body>
</html>

Output:

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :