Magento Expert Forum - Improve your Magento experience

Results 1 to 4 of 4

How to call dropdown using javascript onchange ?

  1. #1
    Junior Member clapcreative's Avatar
    Join Date
    Jul 2015
    Location
    149 Mcafee court , Thousand Oaks CA 91360
    Posts
    115
    Thanks
    3
    Thanked 6 Times in 6 Posts

    Default How to call dropdown using javascript onchange ?

    Code:
    <script>
    jQuery.noConflict()(document).ready(function() {
    $('#hide').css('display','none');
    $('#plano').change(function(){
    
    if(document.getElementById('plano').value == 1){
    $('#hide').show('slow');
    
    }else
    if(document.getElementById('plano').value == 0){
    
    $('#hide').hide('slow');
    }else
    if(document.getElementById('plano').value == 0){
    $('#hide').css('display','none');
    
    }
    
    });
    $('#plano').change();
    });
    </script>

    View more threads in the same category:


  2. #2
    Junior Member
    Join Date
    Jun 2016
    Location
    Bhavnagar, Gujarat, India
    Posts
    1,125
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default

    If you need to call any function on dropdown, change event then use onchange property of dropdown. Write any function name there and code that function according to your requirement.

  3. #3
    Junior Member
    Join Date
    Aug 2016
    Posts
    72
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default

    <select id="leave">
    <option value="5">Get Married</option>
    <option onchange="changeMessage()" value="100">Let's have a baby</option>
    <option value="90">Adopt a Child</option>
    <option value="15">Retire</option>
    <option value="15">Military Leave</option>
    <option value="15">Medical Leave</option>
    </select>

    <div id="message"></div>

    Javascript

    function changeMessage() {
    document.getElementById("message").innerHTML = "Let's have a baby!!";
    }

  4. #4
    Junior Member
    Join Date
    Sep 2018
    Location
    Oman, Muscat
    Posts
    2,084
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default

    cmbexch.Attributes.Add("onChange", "return OnSelectedIndexChange();") <code> OnSelectedIndexChange()</code> should be your Javascript function that will be call <code>DropDownList </code> Seleted index is changes. You can also pass the object to get the value of selected item as well.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •