javascript - Hide input fields by default and show it when selecting a value from select field -


in code, have 1 select field , 2 read fields. need hide read fields default (while loading page) , need show these fields if of value selected select field. values select field getting mysql data base using php.

<select id ="name" name="name" class="form-control" required>     <option value="" disabled selected>choose wallet</option>      <?php     //my query            echo '<option value="' . $row['group'] . '">' . $row['group'] . '</option>';      ?>  </select>  <input id ="od" value="<?php echo $od ?>" class="form-control" readonly/> <input id="bal" value="<?php echo $bal ?>" class="form-control" readonly/> 

try

function onnamechange() {    var name = document.getelementbyid('name');    document.getelementbyid('od').style.display = name.value ? 'inline-block' : 'none'    document.getelementbyid('bal').style.display = name.value ? 'inline-block' : 'none'  }
<!-- use change event handler select -->  <select id="name" name="name" class="form-control" onchange="onnamechange()" required>    <option value="" disabled selected>choose wallet</option>    <option value="1">1</option>    <option value="2">2</option>    <option value="3">3</option>  </select>    <!-- hide inputs using `display: none` -->    <input id="od" value="<?php echo $od ?>" class="form-control" style="display: none" readonly/>  <input id="bal" value="<?php echo $bal ?>" class="form-control" style="display: none" readonly/>


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -