Replace and display a new page after value getting selected from dropdown in jsp

前端 未结 1 1432
执念已碎
执念已碎 2021-01-26 03:38

I have a dashboard where I have multiple drop down values, one of the drop-down have values which when get selected and a submit button is clicked it replaces the existing page

相关标签:
1条回答
  • 2021-01-26 04:04
    <script type="text/javascript">
        function showlevel1() {
            var l1 = document.getElementById('level1_category');
            l1.style.display = 'block';
            var l2 = document.getElementById('level2_category');
            l2.style.display = 'none';
        }
    
        function showlevel2() {
            var l2 = document.getElementById('level2_category');
            l2.style.display = 'block';
            var l1 = document.getElementById('level1_category');
            l1.style.display = 'none';
    
        }
        function categorySelectHandler(select) {
    
            if (select.value == '1') {
    
                var l1 = document.getElementById('level1_category');
                l1.style.display = 'none';
                var l2 = document.getElementById('level2_category');
                l2.style.display = 'none';
    
            } else if (select.value == '2') {
                showlevel1();
            } else if (select.value == '3') {
                showlevel2();
            }
    
    
        }
    </script>
    
    
    <html>
    <select id="select_level" onchange="categorySelectHandler(this)">
          <option value="1">Create at level 1</option>
          <option value="2">Create at level 2</option>
          <option value="3">Create at level 3</option>
    </select>
    
    
    <div id="level1_category"  style="display:none;">
    
    //   # Your Code Here
    
    </div>
    
    <div id="level2_category"  style="display:none;">
    
    //   # Your Code Here
    
    </div>
    </html>
    
    0 讨论(0)
提交回复
热议问题