jquery警告框未显示

时间:2014-03-25 12:50:20

标签: javascript php jquery html ajax

我在双击alert时尝试显示td(clientprice)框,但是没有显示警告,任何人都可以指导我如何显示提示框。

我的完整代码:

<?php
$dbHost = 'localhost'; // usually localhost
$dbUsername = 'xxxxxx';
$dbPassword = 'xxxxxxxxxx';
$dbDatabase = 'xxxxxxxx';
$db = mysql_connect($dbHost, $dbUsername, $dbPassword) or die ("Unable to connect to Database Server.");
mysql_select_db ($dbDatabase, $db) or die ("Could not select database.");

$client_id=$_POST['title'];
$route=$_POST['route'];
$country=$_POST['country'];

?>

<html>
<head>

<div id="loading"></div>
        <div id="container">
            <div class="data"></div>


<div class="pagination"></div>

<div style="position: relative;">

<form name="welcomeDiv1" id="welcomeDiv1">
<tr class="unsortable" >
 <select name="client" id="client" style="margin:1px 0 0 1px;background-color:#E8E8E8;width:72px;position: absolute;height:22px;"> 
<option value="">Select Client</option>
<?php
$sql=mysql_query("select * from client_list ORDER BY `clientid` ASC");
$client_id=$_POST['title'];
while($row=mysql_fetch_assoc($sql))
{
if(strlen($_POST['title'])>0 && $_POST['title']==$row['clientid'])
{
print' <option id="client" name="client" value="'.$row['clientid'].'" selected>'.$row['clientid'].' </option>';
}
else{
print' <option id="client" name="client" value="'.$row['clientid'].'">'.$row['clientid'].' </option>';
}
}
?>
</select>
<div id="result"></div>

 </tr>
 </form>

    </div>

</head>


    <body>

<table id="CPH_GridView1"  >

<thead class="fixedHeaderclientnetworkpricelist">
<tr>
<th style=" width:69px">Clien ID  <a  class="accending"> <img id="logo"  src="/image/arrow2.png" style="margin:4px 0 0 2px;cursor:pointer;position: absolute;"></a><a  class="decending"> <img id="logo"  src="/image/arrow1.png" style="margin:12px 0 0 2px;cursor:pointer;position: absolute;"> </a> 
 </th>
<th style=" width:101px" >Region   <a  class="accending"> <img id="logo"  src="/image/arrow2.png" style="margin:4px 0 0 36px;cursor:pointer;position: absolute;"></a><a  class="decending"> <img id="logo"  src="/image/arrow1.png" style="margin:12px 0 0 36px;cursor:pointer;position: absolute;"> </a> 
<input id="CPH_GridView1_region" name="CPH_GridView1_region" onkeyup="searchRows('CPH_GridView1')"  style="background-color:#E8E8E8;width:98px;margin:-33px 0 0 -49px;position: absolute;" type="text" />
 </th>

<th style=" width:119px">Country  <a  class="accending"> <img id="logo"  src="/image/arrow2.png" style="margin:4px 0 0 48px;cursor:pointer;position: absolute;"></a><a  class="decending"> <img id="logo"  src="/image/arrow1.png" style="margin:12px 0 0 48px;cursor:pointer;position: absolute;"> </a> 


    <select id="country" name="country" style="margin:-33px 0 0 -53px;background-color:#E8E8E8;width:116px;position: absolute;height:22px;" >
        <option value="">Country</option>
<?php
$sql=mysql_query("SELECT DISTINCT country FROM globalnetwork ORDER BY country ASC");
$country=$_POST['country'];
while($row=mysql_fetch_assoc($sql))
{
if(strlen($_POST['country'])>0 && $_POST['country']==$row['country'])
{
print' <option id="country" name="country" value="'.$row['country'].'" selected>'.$row['country'].' </option>';
}
else{
print' <option id="country" name="country" value="'.$row['country'].'">'.$row['country'].' </option>';
}
}
?>
</select>

 </th>

<th style=" width:187px">Network Name  <a  class="accending"> <img id="logo"  src="/image/arrow2.png" style="margin:4px 0 0 70px;cursor:pointer;position: absolute;"></a><a  class="decending"> <img id="logo"  src="/image/arrow1.png" style="margin:12px 0 0 70px;cursor:pointer;position: absolute;"> </a> 
<input id="CPH_GridView1_networkname" name="CPH_GridView1_networkname" onkeyup="searchRows('CPH_GridView1')"  style="background-color:#E8E8E8;width:184px;margin:-33px 0 0 -103px;position: absolute;" type="text" />
 </th>

<th style="text-align:center; width:40px" >MCC
<input id="CPH_GridView1_mcc" name="CPH_GridView1_mcc" onkeyup="searchRows('CPH_GridView1')"  style="background-color:#E8E8E8;width:36px;margin:-33px 0 0 -36px;position: absolute;" type="text" />
</th>

<th style="text-align:center; width:40px" >MNC
<input id="CPH_GridView1_mnc" name="CPH_GridView1_mnc" onkeyup="searchRows('CPH_GridView1')"  style="background-color:#E8E8E8;width:38px;margin:-33px 0 0 -37px;position: absolute;" type="text" />
</th>

<th style="text-align:center; width:40px" >MNP
<input id="CPH_GridView1_mnp" name="CPH_GridView1_mnp" onkeyup="searchRows('CPH_GridView1')"  style="background-color:#E8E8E8;width:38px;margin:-33px 0 0 -35px;position: absolute;" type="text" />
</th>

<?php

$ColumnNames = mysql_query("SELECT column_name FROM information_schema.COLUMNS WHERE table_name = 'supplierprice' AND column_name NOT
IN ('supp_price_id','region', 'country','net_id','networkname', 'mcc', 'mnc', 'mnp'
)") or die("mysql error"); 

$columnArray=array();
$i=0;
while($rows=mysql_fetch_array($ColumnNames))
{

$columnArray[]=$rows[0];

echo "<th style='width:67px;' class='. $columnArray[$i] .' >" . $columnArray[$i] . " 
            </th>";

$i++;
}


?>

<th style="text-align:center ;width:101px">Client Price </th>

<th style="text-align:center ;width:120px"><img id=''  src='/image/refresh.png'  style='margin:0 0 0 -22px; cursor: pointer;'><img id='Status'  src='/image/Decreasef.png'  style='margin:0 0 0 7px; cursor: pointer;'><img id='Statusequal'  src='/image/Equalf.png'  style='margin:0 0 0 0px; cursor: pointer;'>

</th>

<th style="text-align:center ;width:141px">Supplier Route

<select name="route" id="route" style="margin:-3px 0 0 -123px;background-color:#E8E8E8;width:140px;position: absolute;"> 
<option value="">Select Route</option>

<?php
$sql_route="SELECT route FROM routestable WHERE `clientid` = '$client_id' ";
$query = mysql_query($sql_route);
while ($row = mysql_fetch_assoc($query))  
{  
if(strlen($_POST['route'])>0 && $_POST['route']==$row['route']){
print' <option id="route" name="route" value="'.$row['route'].'" selected>'.$row['route'].' </option>';}
else{
print' <option id="route" name="route" value="'.$row['route'].'"  >'.$row['route'].' </option>';
}
}   
?>
</select>


</th>


<th style="text-align:center ; width:32px">

<img  id='redirect'  src="/image/exporttt.png"  style="margin:-30 0 0 0px;cursor:pointer;"  >
</th>

</tr>

</thead>


<tbody id="fbody" class="fbody" style="width:1715px" >
<div id="content">

<?php

$client_id  = $_POST['title'];
if($client_id!=""){

$page = $_POST['page'];
$cur_page = $page;
$page -= 1;
$per_page = 50;
$previous_btn = true;
$next_btn = true;
$first_btn = true;
$last_btn = true;
$start = $page * $per_page;

$sql_selectsupplier  = "select * from supplierprice a JOIN  `$client_id` b WHERE b.`net_id` = a.`supp_price_id`";


            if ($country !=""){
                      $sql_selectsupplier.=" AND country = '".$country."'";     

            }else{

                $sql_selectsupplier.=" ORDER BY `country` ASC LIMIT $start, $per_page ";


            }


//print  $sql_selectsupplier;

$result1 = mysql_query($sql_selectsupplier);



//print "query". $query;

while($rows=mysql_fetch_array($result1))
{


    $routereditect[]=$rows['seleniumrouteupdate'];

    $list = implode($routereditect, ",");





if($alt == 1)
        {
           echo '<tr class="alt">';
           $alt = 0;
        }
        else
        {
           echo '<tr>';
           $alt = 1;
        }

echo '   <td style="width:69px" class=" '.$rows["net_id"].'">'.$rows["clientid"].'</td>
         <td style="width:101px" id="CPH_GridView1_clientid" class=" '.$rows["net_id"].'">'.$rows["region"].'</td>  
        <td style="width:119px" id="CPH_GridView1_country" class=" '.$rows["net_id"].'">'.$rows["country"].'</td>
        <td style="width:187px" id="CPH_GridView1_networkname" class=" '.$rows["net_id"].'">'.$rows["networkname"].'</td>
        <td style="width:40px" id="CPH_GridView1_mcc"  class=" '.$rows["net_id"].'">'.$rows["mcc"].'</td>    
        <td style="width:40px"id="CPH_GridView1_mnc"  class="'.$rows["net_id"].'">'.$rows["mnc"].'</td>
        <td style="width:40px" id="CPH_GridView1_mnp" class="'.$rows["net_id"].'">'.$rows["mnp"].'</td>';
  /*                        
         $ColumnNames = mysql_query("SELECT column_name FROM information_schema.COLUMNS WHERE table_name = 'supplierprice' AND column_name NOT
IN ('supp_price_id','net_id','region', 'country', 'networkname', 'mcc', 'mnc', 'mnp'
)") or die("mysql error"); 

$columnArray=array();*/


foreach($columnArray as $value) {


//$columnArray[]=$rows1[0];

echo '<td style="width:67px" id="CPH_GridView1_xxx" width="0px;" class="'.$value.' '.$rows["net_id"].'"><p>'.$rows[$value].'</p></td>';   
}   

 echo '<input type="hidden" name="myid" id="myid" value="CPH_GridView1_Status'.$rows['net_id'].'" class="text">';

 echo ' <td style="width:101px" id="CPH_GridView1_clientprice'.$rows['net_id'].'" class="edit clientprice '.$rows["net_id"].'">'.$rows["clientprice"].'</td>
        <td style="width:120px" id="CPH_GridView1_Status'.$rows['net_id'].'" class="edit2 status '.$rows["net_id"].' "><img  src="image/'.$rows["status"].'f.png" /></td>

        <td style="width:141px" id="CPH_GridView1_route'.$rows['net_id'].'" > <select name="mySelect" id="mySelect" class="edit1 route '.$rows["net_id"].'" >         
           <option value="-1">Choose..</option>';


            $query = "SELECT DISTINCT route FROM routestable WHERE `clientid` = '$client_id' "; 

            $result = mysql_query($query);

            while ($rows1 = mysql_fetch_assoc($result))  
            {  


                    if(strlen($rows1['route'])>0 && $rows1['route']==$rows['route']){
    print' <option value="'.$rows1['route'].'" selected>'.$rows1['route'].' </option>';}

                else{

                echo '<option value="' . $rows1['route'] . '"> ' . $rows1['route'] .     '</option>';  

                }

            }   
        if($rows['seleniumrouteupdate']=="1")
            {

                $checked_value= "checked";
            }

            else{

                $checked_value="";
            }       

         echo '</select>
                            </td>


                     <td style="width:32px" id="CPH_GridView1_rollback'.$rows['net_id'].'" class="edit3 status1 '.$rows["net_id"].' "><img  src="image/refresh.png" style="cursor: pointer;" /></td>        


                        '



        ;



echo '</tr>';

}





/* --------------------------------------------- */
$query_pag_num = "select COUNT( * ) AS count from supplierprice a JOIN `$client_id` b WHERE b.`net_id` = a.`supp_price_id` ORDER BY `country` ASC";
//print $query_pag_num;
$result_pag_num = mysql_query($query_pag_num);
$row = mysql_fetch_array($result_pag_num);
$count = $row['count'];
$no_of_paginations = ceil($count / $per_page);

/* ---------------Calculating the starting and endign values for the loop----------------------------------- */
if ($cur_page >= 7) {
    $start_loop = $cur_page - 3;
    if ($no_of_paginations > $cur_page + 3)
        $end_loop = $cur_page + 3;
    else if ($cur_page <= $no_of_paginations && $cur_page > $no_of_paginations - 6) {
        $start_loop = $no_of_paginations - 6;
        $end_loop = $no_of_paginations;
    } else {
        $end_loop = $no_of_paginations;
    }
} else {
    $start_loop = 1;
    if ($no_of_paginations > 7)
        $end_loop = 7;
    else
        $end_loop = $no_of_paginations;
}
/* ----------------------------------------------------------------------------------------------------------- */
$msg .= "<div class='pagination'><ul>";

// FOR ENABLING THE FIRST BUTTON
if ($first_btn && $cur_page > 1) {
    $msg .= "<li p='1' class='active'>First</li>";
} else if ($first_btn) {
    $msg .= "<li p='1' class='inactive'>First</li>";
}

// FOR ENABLING THE PREVIOUS BUTTON
if ($previous_btn && $cur_page > 1) {
    $pre = $cur_page - 1;
    $msg .= "<li p='$pre' class='active'>Previous</li>";
} else if ($previous_btn) {
    $msg .= "<li class='inactive'>Previous</li>";
}
for ($i = $start_loop; $i <= $end_loop; $i++) {

    if ($cur_page == $i)
        $msg .= "<li p='$i' style='color:#fff;background-color:#006699;' class='active'>{$i}</li>";
    else
        $msg .= "<li p='$i' class='active'>{$i}</li>";
}

// TO ENABLE THE NEXT BUTTON
if ($next_btn && $cur_page < $no_of_paginations) {
    $nex = $cur_page + 1;
    $msg .= "<li p='$nex' class='active'>Next</li>";
} else if ($next_btn) {
    $msg .= "<li class='inactive'>Next</li>";
}

// TO ENABLE THE END BUTTON
if ($last_btn && $cur_page < $no_of_paginations) {
    $msg .= "<li p='$no_of_paginations' class='active'>Last</li>";
} else if ($last_btn) {
    $msg .= "<li p='$no_of_paginations' class='inactive'>Last</li>";
}
$goto = "<input type='text' class='goto' size='1' style='margin-top:-1px;margin-left:60px;'/><input type='button' id='go_btn' class='go_button' value='Go'/>";
$total_string = "<span class='total' a='$no_of_paginations'>Page <b>" . $cur_page . "</b> of <b>$no_of_paginations</b></span>";
$msg = $msg . "</ul>" . $goto . $total_string . "</div>";  // Content for pagination
echo $msg;


}
?>




</div>



</tbody>




</table>

</div>


<div id="alert" style="margin:-840px 0 0 466px">

</div>


</body>


</html>

<script>

    $(document).ready(function(){


                              function showAlertBox(){

     $("#alert").css("display","inherit");
     $('td.edit').addClass("back");

    }


    function removeAlertBox(){
        $("#alert").css("display","none");
         $('td.edit').removeClass("back");        
    }

    $("#alertClose").click(function(){
       removeAlertBox(); 
    });

      $(document).click(function(e){
        removeAlertBox();
    });

    $(".edit").dblclick(function(){


       showAlertBox(); 
    });



     $('td.edit').dblclick(function() {                
arr = $(this).attr('class').split( " " );
var clientid=document.getElementById("client").value;
      $.ajax({    //create an ajax request to load_page.php
        type: "POST",
        url: "clientnetworkpricelist/clientnetworkhistory.php",             
        dataType: "html",   //expect html to be returned
        data: "value="+$('.ajax input').val()+"&rowid="+arr[2]+"&field="+arr[1]+"&clientid="+clientid,  


        success: function(response){


            $("#alert").html(response); 



           // alert(response);
             $("#alertClose").click(function(){
       removeAlertBox(); 
    });
          //alert(response);
          $( "#alert" ).draggable();  
        }


    });
});     




        $('td.edit').keydown(function(event){


                                     arr = $(this).attr('class').split( " " );
                                     var clientid=document.getElementById("client").value;
                                     account_id=document.getElementById("account_id").value;


                                     if(event.which == 13)
                                     { 

                                        $.ajax({    type: "POST",
                                                    url:"clientnetworkpricelist/update.php",
                                                    data: "value="+$('.ajax input').val()+"&rowid="+arr[2]+"&field="+arr[1]+"&clientid="+clientid+"&account_id="+account_id,
                                                    success: function(res){

                                                         $("#container").ajaxComplete(function(event, request, settings)
                            {

                                data = jQuery.parseJSON(res); //added line

                $('#CPH_GridView1_clientprice'+arr[2]).empty();
                $('#CPH_GridView1_clientprice'+arr[2]).append(data.price); //changed
                $('#CPH_GridView1_Status'+arr[2]).empty();
                $('#CPH_GridView1_Status'+arr[2]).append(data.statusimage);

                                                         });



                                                    }});
                                     }

                                  }

                                  );




        $('#editbox').on('blur',function(){

                                     $('.ajax').html($('.ajax input').val());
                                     $('.ajax').removeClass('ajax');
                                    });



    });


</script>

1 个答案:

答案 0 :(得分:0)

你的演示不起作用的原因是你的代码中有以下行,它调用了一个名为$ input的未定义变量:

代码JavaScript:

$input.prop('disabled', true);

请参阅以下链接,了解我已清理并开始工作的演示版的更新版本。

http://jsfiddle.net/YMs4q/29/