选择下拉值无法隐藏特定的div。这是我的代码。在codeigniter中选择下拉值时隐藏特定div
查看:
function showRequiredOption(cval)
\t {
\t \t if(cval=='interstate')
\t \t {
\t \t \t $('#cgst').hide();
\t \t \t $('#sgst').hide();
\t \t \t
\t \t }
\t \t else if(cval=='exemptedsales')
\t \t {
\t \t \t $('#cgst').hide();
\t \t \t $('#sgst').hide();
\t \t \t $('#igst').hide();
\t \t \t
\t \t }
\t \t else
\t \t {
\t \t \t $('#igst').hide();
\t \t \t $('#cgst').show();
\t \t \t $('#sgst').show();
\t \t \t
\t \t }
\t }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-md-9 col-md-offset-2">
\t <div id="legend">
\t \t <legend class="">Profile Information</legend>
\t </div>
<form role= action="<?php echo site_url();?>invoice/addinvoice" method="post" class="form-horizontal" id="location" method="post" accept-charset="utf-8"> \t \t
\t \t <div class="form-group">
\t \t \t <label class="control-label col-sm-2 " for="user">User</label>
\t \t \t <div class="col-sm-4 col-sm-offset-1">
\t \t \t \t <select id="user" name="user" onchange="showRequiredOption(this.value);">
\t \t \t \t \t <option value="employee">Local Sales</option>
\t \t \t \t \t <option value="interstate">Inter state</option>
\t \t \t \t \t <option value="freelancer">Stock transfers</option>
\t \t \t \t \t <option value="exemptedsales">Exempted Sales</option>
\t \t \t \t \t <option value="company">Zero Rated Sales</option>
\t \t \t \t \t <option value="freelancer">Job Work</option>
\t \t \t \t </select>
\t \t \t </div>
\t \t </div> \t \t
\t \t <div class="form-group">
\t \t <label class="control-label col-sm-2 " for="hsn">Freight Charges</label>
\t \t <div class="col-sm-4 col-sm-offset-1">
\t \t \t <input type="text" class="form-control" id="hsn" placeholder="Enter HSN Number" >
\t \t </div>
\t \t </div>
\t \t
\t \t <div class="form-group" id="igst">
\t \t <label class="control-label col-sm-2 " for="hsn">IGST 18%</label>
\t \t <div class="col-sm-4 col-sm-offset-1">
\t \t \t <input type="text" class="form-control" id="hsn" placeholder="Enter HSN Number" >
\t \t </div>
\t \t </div> \t
\t \t <div class="form-group" id="sgst">
\t \t <label class="control-label col-sm-2 " for="hsn">SGST 9%</label>
\t \t <div class="col-sm-4 col-sm-offset-1">
\t \t \t <input type="text" class="form-control" id="sgst" placeholder="Enter HSN Number" >
\t \t </div>
\t \t </div> \t
\t \t <div class="form-group" id="cgst">
\t \t <label class="control-label col-sm-2 " for="hsn">CGST 9%</label>
\t \t <div class="col-sm-4 col-sm-offset-1">
\t \t \t <input type="text" class="form-control" id="cgst" placeholder="Enter HSN Number" >
\t \t </div>
\t \t </div> \t \t \t
<button id="submit" type="submit" class="btn" name="submit">Submit</button>
</form>
</div>
这儿如果我在下拉列表中选择CGST州际,股票转让,SGST应墙根和IGST应显示。
如果我选择了豁免销售额,零额定销售额,下拉IGST,CGST,SGST的工作量应该被隐藏。
默认情况下,它应该显示SGST和CGST
@AndrewLi:很高兴知道,但是在那段代码中没有PHP代码,当然不足以让代码片断。 –