Postingan lainnya
Kelas Premium!
Belajar bikin website dari nol sekarang
Gunakan kupon "lebihcepat" untuk diskon 25%!
Kelas Premium!
Belajar Javascript untuk website
Gunakan kupon "mulaijs" untuk diskon 75 ribu!
Cara menampilkan kolom input jika
misi gan, ane mau nanya lagi nih ane ada 3 option kategori, contoh nya 1, 2, sama 3 nah kalo di pilih 1 sama 2 itu ga nampilin kolom input tapi kalo di pilih nomor 3 nampilin kolom input contoh kyak di gambar contoh kalo di pilih kategori 1 dan 2 contoh kalo di pilih kategori 3 makasih gan sebelumnya
4 Jawaban:
bisa pake jquery css <pre> $("#kategori").change(function(){ if($(this).val() == 1 && $(this).val() == 2) { $("#check").css("display","block"); $("#textarea").css("display","none"); } else { $("#check").css("display","none"); $("#textarea").css("display","block"); } }); </pre>
Tanggapan
Belom bisa juga om, apa ane yg salah ya, coba referensi nya om
coba code yg agan bikin taruh diatas
itu om codenya
@dianarifr
<pre> <script> $("#category").change(function(){ if($(this).val() == 1 && $(this).val() == 2) { $("#check").css("display","block"); $("#textarea").css("display","none"); } else { $("#check").css("display","none"); $("#textarea").css("display","block"); } }); </script>
&lt;div class="card-body card-padding"&gt;
&lt;!-- start content --&gt;
&lt;form class="form-horizontal" method="POST"&gt;
&lt;div class="form-group"&gt;
&lt;label class="col-md-12"&gt;Category&lt;/label&gt;
&lt;div class="col-md-12"&gt;
&lt;select class="form-control" name="category" id="category"&gt;
&lt;option value="0"&gt;Pilih salah satu&lt;/option&gt;
&lt;option value="1"&gt;1&lt;/option&gt;
&lt;option value="2"&gt;2&lt;/option&gt;
&lt;option value="3"&gt;3&lt;/option&gt;
&lt;/select&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="form-group"&gt;
&lt;div class="col-md-12"&gt;
&lt;label&gt;Username/Link&lt;/label&gt;
&lt;input type="text" class="form-control" name="link" placeholder="Username/Link" required&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="form-group"&gt;
&lt;div class="col-md-12"&gt;
&lt;label&gt;Input Komentar&lt;/label&gt;
&lt;textarea name="textarea" style="display: none;"&gt;&lt;/textarea&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="form-group"&gt;
&lt;div class="col-md-6"&gt;
&lt;label&gt;Jumlah&lt;/label&gt;
&lt;div&gt;
&lt;input type="hidden" class="form-control" id="rate"&gt;
&lt;input type="number" class="form-control" name="quantity" id="quantity" placeholder="Jumlahnya" onkeyup="getcut(this.value).value;" required&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="form-group m-b-0"&gt;
&lt;div class="col-md-12"&gt;
&lt;button type="submit" class="btn btn-info waves-effect waves-light" id="order" name="order"&gt;&lt;i class="ion ion-ios-cart"&gt;&lt;/i&gt; Add &lt;/button&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/form&gt;
&lt;!-- end content --&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;!-- col --&gt;
</pre>
coba ini, id dan name sesuaikan kebutuhan <pre><script> $("#category").change(function(){ if($(this).val() != 3) { $("#textarea").hide(); $("#check").show(); } else { $("#textarea").show(); $("#check").hide(); } }); </script> <div class="card-body card-padding"> <!-- start content --> <form class="form-horizontal" method="POST"> <div class="form-group"> <label class="col-md-12">Category</label> <div class="col-md-12"> <select class="form-control" name="category" id="category"> <option value="0">Pilih salah satu</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> </div> </div> <div class="form-group"> <div class="col-md-12"> <label>Username/Link</label> <input type="text" class="form-control" name="link" placeholder="Username/Link" required> </div> </div> <div class="form-group"> <div class="col-md-12"> <label>Input Komentar</label> <textarea name="textarea" id="textarea" style="display: none;"></textarea> <p id="check" style="display: none;"> <input type="radio" name="check">drip-feed </p> </div> </div> <div class="form-group"> <div class="col-md-6"> <label>Jumlah</label> <div> <input type="hidden" class="form-control" id="rate"> <input type="number" class="form-control" name="quantity" id="quantity" placeholder="Jumlahnya" onkeyup="getcut(this.value).value;" required> </div> </div> <div class="form-group m-b-0"> <div class="col-md-12"> <button type="submit" class="btn btn-info waves-effect waves-light" id="order" name="order"><i class="ion ion-ios-cart"></i> Add </button> </div> </div> </form> <!-- end content --> </div>
</div> </pre>