javascript - Call Function with param -


i created these 2 functions call each other can not see why can not call function iofunction(). can doing wrong?

this way call function:

$("[name=flip-4]").change(function() {     var b = $("#flip-2").val();     var c = $("#flip-3").val();     var d = $("#flip-4").val();       if (b == "on" || c == "on" && d == "off") {         var message = 'the roof cant close when setups on.';          dialogfunction(message);          $("#flip-4").val("on");                         } else {         var message = 'the roof ' + d + ': ' + output + '.';                                            var flip = 'flip4';          iofunction(flip,d,message);     } });  function dialogfunction(param) {     var html = '<div data-role="dialog" id="page2" data-mini="true" data-close-btn="right">';     html += '<div data-role="header"><h1 style="text-align:left; margin-left:10px;">atention</h1></div>';     html += '     <div role="main" class="ui-content">';     html += '          <legend>' + param +'</legend>  ';     html += '     </div>';     html += '     </div>';      $('#page2').remove();     $('body').append(html);     $('#page2').enhancewithin();      $.mobile.changepage("#page2"); }  function iofunction(parama,paramb,paramc) {     $.ajax({         url: 'io.php?'+ parama + '=' + paramb,         datatype: 'text',         success: function(output){             var output = $.trim(output);             if (output == "success") {                 dialogfunction(paramc);             } else {                 dialogfunction('error: ' + output);             }         }     }); }    

i think problem lies in if statement:

if (b == "on" || c == "on" && d == "off") { 

do mean:

if ((b == "on" || c == "on") && d == "off") {     

or

if (b == "on" || (c == "on" && d == "off")) {   

? think putting parentheses around conditions make more explicit.

i'm willing bet if put breakpoint / console.log or inside else, never reach it.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -