【发布时间】:2016-10-06 06:36:33
【问题描述】:
这是我的脚本
$(document).ready(function () {
$("#txtfrom").hide();
$("#txtto").hide();
$("#txtvenue").hide();
$("#drdsearch").text == "Venue Name"(function () {
$("#txtfrom").hide();
$("#txtto").hide();
$("#txtvenue").show();
});
$("#drdsearch").text == "Date"(function () {
$("#txtfrom").show();
$("#txtto").show();
$("#txtvenue").hide();
});
});
这些是我的控件
<div>
<p style="margin-top:-24px;">
<b style="font-size:16px; margin-left:180px;">Search By:</b>
</p>
<select id="drdsearch" style="margin-top:-39px; margin-left:300px; height:30px; width:200px; font-size:12px;">
<option>Default</option>
<option>Venue Name</option>
<option>Date</option>
</select>
</div>
<div style="margin-left:300px">
<p style="font-family: Verdana">
<asp:TextBox ID="txtvenue" runat="server" CssClass="txttopborder font" ng-model="venue" Text="" placeholder="venue" Height="30" Width="200"></asp:TextBox>
<asp:TextBox ID="txtfrom" runat="server" style="margin-left:-300px;" CssClass="txttopborder font" ng-model="from" placeholder="From Date" Text="" Height="30" Width="200"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="clndrfrom" runat="server" TargetControlID="txtfrom" Format="dd-MM-yyyy"></ajaxToolkit:CalendarExtender>
<asp:TextBox ID="txtto" runat="server" CssClass="txttopborder font" ng-model="to" Text="" placeholder="To Date" Height="30" Width="200"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="clndrto" runat="server" TargetControlID="txtto" Format="dd-MM-yyyy"></ajaxToolkit:CalendarExtender>
<%-- <button type="button" ng-click="Addrecord(x)" style="height:30px; width:50px;" class="btn btn-sm btn-primary active" data-toggle="modal" data-target="#Detailsmodel"><i class="glyphicon glyphicon-search" style="font-size:20px;"></i></button> --%>
</p>
</div>
我正在创建一个 Web 应用程序,其中我从下拉列表中为用户提供了 3 个选项 1) 默认 2) 场地名称 3) 日期
默认情况下,Default 被选中,如果用户选择场地名称,txtvenue 应该是可见的,txtfrom,txtto 隐藏,
如果用户选择日期txtvenue 应该被隐藏并且txtfrom,`txt 可见
我在我的页面上添加了这个脚本
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
但是,所有控件都是可见的,并且下拉文本更改时没有发生任何事情。
【问题讨论】:
-
我建议你为每个选项赋予价值