Skip to content

Instantly share code, notes, and snippets.

@AndrewEddy
Created May 19, 2015 17:47
Show Gist options
  • Select an option

  • Save AndrewEddy/683864556e8e37f15fba to your computer and use it in GitHub Desktop.

Select an option

Save AndrewEddy/683864556e8e37f15fba to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>HTML Form</title>
</head>
<body>
<form>
<p>First Name:</p>
<input type="text" name="firstname" placeholder="First Name">
<p>Last Name:</p>
<input type="text" name="lasttname" placeholder="Last Name"><br>
<textarea name="content"></textarea>
<p>Select your favorite fruit.</p>
<select name="fruit">
<option value="apple">Apple</option>
<option value="apple">Strawberry</option>
<option value="apple">Kiwi</option>
<option value="apple">Watermelon</option>
</select>
<input type="submit">
</form>
</body>
</html>
@Amanchib
Copy link

Amanchib commented Mar 5, 2021

Good

@DURGESAMSRINATH
Copy link

gud

@NoSoyRo
Copy link

NoSoyRo commented Nov 14, 2022

okok

@verfed
Copy link

verfed commented Jul 23, 2023

Cool.

@General-Pinochet
Copy link

why are we giving value up here option value="apple">Apple</option

what happen if we lave it as option value="">Apple</option .?

the value attribute is for the developer. think of it like this, we are displaying the name apple there and as we assign a value to it, we are saying to the parser that, if they select apple, the value should be "apple" and this value will be later used for further processing. And if we do as you asked and leave the value null or "" even if we select apple in the checkbox, there will be no further action that can be taken with your option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment