Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

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

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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:


My Personal Notes arrow_drop_up
Last Updated : 26 Mar, 2021
Like Article
Save Article
Similar Reads
Related Tutorials