Auswahl Dropdown-Wert nicht in der Lage, bestimmte divs.Hieris mein Code zu verstecken.Verbergen bestimmter divs bei der Auswahl Dropdown-Werte in coderigniter
Ausblick:
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>
hier, wenn ich zwischenstaatlichen wählen, Umlagerungen in Drop-Down-CGST, SGST ausgeblendet werden soll und IGST angezeigt werden sollen.
Wenn ich Ausgenommene Verkäufe, Zero Rated Verkäufe, Arbeit im Dropdown-Menü IGST, CGST, SGST auswählen sollte ausgeblendet werden.
standardmäßig sollte es zeigen SGST und CGST
@AndrewLi: schön zu wissen, aber es gab wenig-zu-keine PHP-Code in diesem Snippet, sicherlich nicht genug für das Snippet zu brechen. –