How to debug using firebug and show the value of radio button

前端 未结 2 991
我寻月下人不归
我寻月下人不归 2021-01-26 06:08

I have radio buttons as shown below.

        
相关标签:
2条回答
  • 2021-01-26 06:13

    In your javascript you are getting the value of the div, not the radio button:

    $('#lensType').val() <--- change that
    

    To something like this:

    $("#lensType input:radio[name='design']:checked").val()
    
    0 讨论(0)
  • 2021-01-26 06:28

    for debugging:

    $('input[name="design"]').change(function(){ 
    console.log($('#lensType').find("input:radio[name ='design']:checked").val());
    });
    

    else:

    $('#lensType').find("input:radio[name ='design']:checked").val();
    

    instead of

    $('#lensType').val()
    

    and you probably want to wrap it witg a changed function, since onload no design is selected:

      $(document).ready(function(){
    $('input[name="design"]').change(function(){ 
    var design = $('input[name="design"]:checked').val();
         function populate() {
          fetch.doPost('getSupplier.php');
       }
    
     $('#lensType').change(populate);
    
      var fetch = function() {
    
     var counties = $('#county');
    
    return {
    doPost: function(src) {
    
    $('#loading_county_drop_down').show(); // Show the Loading...
    $('#county_drop_down').hide(); // Hide the drop down
    $('#no_county_drop_down').hide(); // Hide the "no counties" message (if it's the case)
    
    
        if (src) $.post(src, { supplier: design }, this.getSupplier);
    
        else throw new Error('No source was passed !');
    },
    
    getSupplier: function(results) {
        if (!results) return;
        counties.html(results);
    
    $('#loading_county_drop_down').hide(); // Hide the Loading...
    $('#county_drop_down').show(); // Show the drop down
    }   
      }
     }();
    
     populate();
    });
     });
    
    0 讨论(0)
提交回复
热议问题