通过onchange事件将SELECT的值传递给Javascript函数? [英] Pass the value of a SELECT to a Javascript function via the onchange event?
问题描述
我有一个HTML页面,其中包含一个包含多个文本框的搜索框。
I have a HTML page that contains a search box containing a number of textboxes.
搜索框的第一部分是 SELECT 下拉列表,其中包含各种报表类型。每个报表类型都需要填写一个或多个文本框以过滤查询结果。我的目标是隐藏当前报告类型不需要的文本框。
The first part of the search box is a SELECT dropdown list that contains a variety of report types. Each report type requires 1 or more of textboxes to be filled in to filter the query results. My goal is hide the textboxes that are not required by the current report type.
如何将当前选定的值从 > SELECT 通过 onchange 事件发送到Javascript函数。
How do I pass the currently selected value from the SELECT to the Javascript function via the onchange event?
<select name="report_type" onchange="hide();">
<option value="full_history">Full History</option>
<option value="partial_history">Partial History</option>
</select>
推荐答案
<select name="report_type" onchange="hide(this.value);">
<option value="full_history">Full History</option>
<option value="partial_history">Partial History</option>
</select>
当这样做时,该功能具有当前选择的任何值。
When doing this the function have whatever value the select currently has.
这篇关于通过onchange事件将SELECT的值传递给Javascript函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!