I have drop down of some choice where last option is "Other".
I want to display text field when user select other option from drop down.
I am using normal html, Sorry I am AMP beginner, I found some example of amp-list with json option, but i don't know how to implement as i have limited options in drowpdown.
<select data-type="text" id="cuisine" name="cuisine" required>
<option value="german">German wine</option>
<option value="baden">Baden cuisine</option>
<option value="hamburg">Hamburg cuisine</option>
<option value="others">Others</option>
<select>
<div class="form-group hide" id="other_cusone">
<label for="other_city_p" class="active">Other :</label>
<input type="text" id="other_c_p" name="other" placeholder="Other">
</div>
thanks
For limited option you don't have to use amp-list, it is for dynamic dropdown. you can achieve your goal by using amp-bind.
Code:
<!doctype html>
<html ⚡>
<head>
<meta charset="utf-8">
<title> AMP amp-bind </title>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
<link rel="canonical" href="https://ampbyexample.com/introduction/hello_world/">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp-custom>
</style>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
</head>
<body>
<select on="change:AMP.setState({ option: event.value })" data-type="text" id="cuisine" name="cuisine" required>
<option value="german">German wine</option>
<option value="baden">Baden cuisine</option>
<option value="hamburg">Hamburg cuisine</option>
<option value="others">Others</option>
</select>
<div hidden [hidden]="option != 'others'" class="form-group hide" id="other_cusone">
<label for="other_city_p" class="active">Other :</label>
<input type="text" id="other_c_p" name="other" placeholder="Other">
</div>
</body>
</html>