<form>
<p><strong>Would you like to receive the Stay Safe newsletter</strong>
<select name="newsletter">
<!-- dropdown box allows user to select if they want to receive newsletter-->
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
</p>
<p><textarea name="message" id="address" placeholder="Address"></textarea></p>
<p><input type="email" name="email" placeholder="Valid email"></p>
<button class="smallButton" type="submit">Send</button>
<!-- submission button to send the form-->
</form>
我需要在编码表单时需要帮助,我只想显示
<p><textarea name="message" id="address" placeholder="Address"></textarea></p>
<p><input type="email" name="email" placeholder="Valid email"></p>
<button class="smallButton" type="submit" >Send</button><!-- submission button to send the form-->
基于它们,在下拉框中选择“是”,但不确定如何执行此操作,将不胜感激
答案 0 :(得分:0)
我会使用onchange
和javascript解决您的问题。这是一些documentation:
<select name="newsletter" onchange="newsletterChanged()">
然后,您可以添加JavaScript以隐藏或显示您想要的html:
function newsletterChanged() {
//do work whenever newsletter changes.
};
希望这可以帮助您解决问题。快乐的编码:-)