将Javascript变量传递给PHP变量以在查询时使用而不重定向

时间:2016-12-08 10:50:57

标签: javascript php jquery sql-server modal-dialog

这是我的问题:

我的输入有onclick事件getRet(' somevalue')传递' somevalue',

retrackView.php - html

<input type="text" style="border: 0; color:blue;" id="return_type"
class="return_type" name="return_type" data-toggle="modal" 
data-target="#myModalSS_SKU" data-remote="false" readonly="readonly"
title="Click Me" value="<?=$objResult["RETURN_TYPE"];?>" 
onclick="getRet('<?=$objResult["RETURN_TYPE"];?><?=$objResult["IMEI"];?>');">

我还有一个javascript函数可以发布一些值&#39;

retrackView.php - 内部

function getRet(ret) {
    $.ajax({
      type: "POST",
      url: 'retrackView.php',
      data: ({"data1": ret}),
      success: function(data) {
        alert(data);
      }
    });
}

我在模态中有一个PHP脚本来获取&#39; somevalue&#39;在查询中使用以填充模态值

retrackView.php - 在PHP内部

$strSQL1 = "select * from sch_orders where return_type + IMEI = '.$_POST['data1'].'";

$result2=sqlsrv_query( $conn,$strSQL1, $params2,array( "Scrollable" => 'keyset')); 
while($objResult1 = sqlsrv_fetch_array( $result2,SQLSRV_FETCH_ASSOC ))

//..... then I used it like : 
<label>
<?if (isset($objResult["DATE_RECEIVED_WHSE"])){ 
    print date('m-d-Y h:i A', strtotime($objResult["DATE_RECEIVED_WHSE"]));
}?>
</label>

问题是.$_POST['data1'].没有值[undefined index:data1]

这是我的一些模态代码:

<div id="myModalSS_SKU" class="modal fade" role="dialog">
      <div class="modal-dialog" style="height:540px; max-height:740px; width:1030px; max-width:1030px;">
        <!-- Modal content-->
        <div class="modal-content">
          <div class="modal-header" style="background-color: #333666;">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title">Retrack-Globe</h4>
          </div>
          <div class="modal-body" style="height:540px; max-height:740px; width:1530px; max-width:1530px;"><!--style=".modal.large{width:10000px;}"-->
                                                                        <?//target="_blank" ?>
            <!--form action="customerView.php" method="post"-->
                <input type="image" src="images/print.png" width="30" height="30" title="print" left= "-100" onclick="window.open('print.php')"> <!--onclick="Print()"--> 
                <!--input style="font-size: 15px;" id="imei"><?=$objResult["IMEI"];?></input>
                </input>
            </form-->

        <? 
        $ret = (isset($_POST["ret"]) ? $_POST["ret"] : 'Track01');
        $serverName = "RLLAMES-PC\MSSQL2005";
            $uid = "sa";
            $pwd = "5chep0d";
            $connectionInfo = array( "UID"=>$uid,
                    "PWD"=>$pwd,
                    "Database"=>"RETRACK",
                    "ReturnDatesAsStrings"=> true);

            $conn = sqlsrv_connect( $serverName, $connectionInfo);          echo($_POST['data1'].'================================================================================');
            $strSQL1 = "select * from sch_orders where return_type + IMEI = 'DSW-STDOANSAMaas16042801681'";
            $params2 = array ($getKeyWord, $getKeyWord, $getKeyWord, $getKeyWord, $getKeyWord, $ret );
            $result2=sqlsrv_query( $conn,$strSQL1, $params2,array( "Scrollable" => 'keyset'));
            while($objResult1 = sqlsrv_fetch_array( $result2,SQLSRV_FETCH_ASSOC )) {
            $var_imei = $objResult1["IMEI"];
            $var_icscase = $objResult1["ICSCase"];
            }

            $strSQL = "select * from sch_orders where (imei  = '" . $var_imei . "'  or newimei = '" . $var_imei . "' ) AND ICSCASE  = '" . $var_icscase . "' " ;
            $params1 = array ($getKeyWord, $getKeyWord, $getKeyWord, $getKeyWord, $getKeyWord, $ret );
            $result1=sqlsrv_query( $conn,$strSQL, $params1,array( "Scrollable" => 'keyset'));
            $count=count($result1);     

             while($objResult = sqlsrv_fetch_array( $result1,SQLSRV_FETCH_ASSOC )) {
            //$ret =  (isset($_GET['ret']) ? $_GET['ret'] : 'TRACK01' );
            //echo $ret; 
            //echo $getKeyWord;

/*if(isset($_GET['txtKeyword'])){
        $getKeyWord = $_GET['txtKeyword'];
        $fieldname = $_GET['cbSearch'];
        $ret = (isset($_POST["ret"]) ? $_POST["ret"] : 'Track01');
        //$ret = $_GET["ret"];
        //echo isset($ret) ? $ret : 'None';

        if ($getKeyWord != ""){
            //echo '1'; die;

            $serverName = "RLLAMES-PC\MSSQL2005";
            $uid = "sa";
            $pwd = "5chep0d";
            $connectionInfo = array( "UID"=>$uid,
                    "PWD"=>$pwd,
                    "Database"=>"RETRACK",
                    "ReturnDatesAsStrings"=> true);

            $conn = sqlsrv_connect( $serverName, $connectionInfo);

            $strSQL = "select * from sch_orders where mobile =  (?) or invoice = (?) or imei = (?)  or newimei = (?) or mybss = (?) " ;
            $params1 = array ($getKeyWord, $getKeyWord, $getKeyWord, $getKeyWord, $getKeyWord, $ret );
            $result1=sqlsrv_query( $conn,$strSQL, $params1,array( "Scrollable" => 'keyset'));
            $count=count($result1);     

             while($objResult = sqlsrv_fetch_array( $result1,SQLSRV_FETCH_ASSOC )) { */?>

        <table>
            <tr>
                <td>
                    <label><?if (isset($objResult["DATE_REQUESTED"])){
                                print date('m-d-Y h:i A', strtotime($objResult["DATE_REQUESTED"]));
                            }?></label>
                </td>
                <td>
                </td>
                <td>
                    <label><?if (isset($objResult["DATE_RECEIVED_WHSE"])){
                                print date('m-d-Y h:i A', strtotime($objResult["DATE_RECEIVED_WHSE"]));
                            }?></label>
                </td>
                <td>
                </td>
                <td>
                    <label><?if (isset($objResult["DATE_FORWARDED_SC"])){
                                print date('m-d-Y h:i A', strtotime($objResult["DATE_FORWARDED_SC"]));
                            }?></label>
                </td>
                <td>
                </td>
                <td>
                    <label><?if (isset($objResult["DATE_RETURNED_WHSE"])){
                                print date('m-d-Y h:i A', strtotime($objResult["DATE_RETURNED_WHSE"]));
                            }?></label>
                </td>
                <td>
                </td>
                <td>
                    <label><?if (isset($objResult["DATE_DELIVERED_STORE"])){
                                print date('m-d-Y h:i A', strtotime($objResult["DATE_DELIVERED_STORE"]));
                            }?></label>
                </td>
            </tr>
            <tr>
                <td>
                    <a href="" title=""><img src="images/drq.png" alt="Smiley face" width="65" height="45"  align="left"></a>
                </td>
                <td>
                    <a href="" title="Go to DB Schenker site"><img src="images/arrow.png" alt="Smiley face" width="45" height="85" align="left"></a>
                </td>
                <td>
                    <a href="" title="<?if (isset($objResult["SLA_DRCW"])){ print "SLA is " .  $objResult["SLA_DRCW"] . " day/s,&#013;Upon date pulled out."; }?>">
                    <img src="images/drcw.png" alt="Smiley face" width="65" height="55"  align="left"></a>
                <? if (isset($objResult["DATE_REQUESTED"]) and isset($objResult["DATE_RECEIVED_WHSE"])) {
                    $date_drq = date_create($objResult["DATE_REQUESTED"]);
                   $date_drcw = date_create($objResult["DATE_RECEIVED_WHSE"]);
                   $drcwDiffs = date_diff($date_drq,$date_drcw);
                   $drcwDiff = $drcwDiffs->format("%R%a days");

                     $drcw = $objResult["SLA_DRCW"]-$drcwDiff;
                    if ($drcw>=0) {?><img src= "images/like.jpg" width="16" height="16" title="like"> <?echo abs($drcw) . 'day/s' ; 
                    }else{?><img src= "images/dislike.jpg" width="16" height="16" title="dislike"> <?echo abs($drcw) . 'day/s'; 
                    } 
                }?>


                </td>
                <td>
                    <a href="" title="Go to DB Schenker site"><img src="images/arrow.png" alt="Smiley face" width="45" height="85" align="left"></a>
                </td>
                <td>
                    <a href="" title="<?if (isset($objResult["SLA_DFSC"])){print "SLA is " .  $objResult["SLA_DFSC"] . " day/s,&#013;Upon date received in whse.";}?>">
                    <img src="images/dfsc.png" alt="Smiley face" width="65" height="55" align="left"></a>   
                    <?if (isset($objResult["DATE_RECEIVED_WHSE"]) and isset($objResult["DATE_FORWARDED_SC"])) {
                   $date_drcw = date_create($objResult["DATE_RECEIVED_WHSE"]);
                   $date_dfsc = date_create($objResult["DATE_FORWARDED_SC"]);
                   $dfscDiffs = date_diff($date_drcw,$date_dfsc);
                   $dfscDiff = $dfscDiffs->format("%R%a days");

                     $dfsc = $objResult["SLA_DFSC"]-$dfscDiff;
                    /*if ($dfsc>=0) {?><img src= "images/like.jpg" width="16" height="16" title="like"> <?echo abs($dfsc) . 'day/s' ; 
                    }else{?><img src= "images/dislike.jpg" width="16" height="16" title="dislike"> <?echo abs($dfsc) . 'day/s'; 
                    }*/
                }?>
                </td>
                <td>
                    <a href="" title="Go to DB Schenker site"><img src="images/arrow.png" alt="Smiley face" width="45" height="85" align="left"></a>
                </td>
                <td>
                    <a href="" title="<?if (isset($objResult["SLA_DRTW"])){print "SLA is " .  $objResult["SLA_DRTW"] . " day/s,&#013;Upon date forwarded in service center.";}?>">
                    <img src="images/drtw.png" alt="Smiley face" width="65" height="55" align="left"></a>
                <?if (isset($objResult["DATE_FORWARDED_SC"]) and isset($objResult["DATE_RETURNED_WHSE"])) {

                   $date_drtw = date_create($objResult["DATE_RETURNED_WHSE"]);
                   $date_drcw = date_create($objResult["DATE_RECEIVED_WHSE"]);
                   $drtwDiffs = date_diff($date_drcw,$date_drtw);
                   $drtwDiff = $drtwDiffs->format("%R%a days");

                      $drtw = $objResult["SLA_DFSC"]-$drtwDiff;
                        if ($drtw>=0) {?><img src="images/like.jpg" width="16" height="16" title="like"> <?echo  abs($drtw) . 'day/s'; 
                        }else{?><img src="images/dislike.jpg" width="16" height="16" title="dislike"> <?echo  abs($drtw) . 'day/s'; 
                        }
                }?>
                </td>
                <td>
                    <a href="" title="Go to DB Schenker site"><img src="images/arrow.png" alt="Smiley face" width="45" height="85" align="left"></a>
                </td>
                <td>
                    <a href="" title="<?if (isset($objResult["SLA_DDS"])){print "SLA is " .  $objResult["SLA_DDS"] . " day/s,&#013;Upon date returned in whse.";}?>"><img src="images/dds.png" alt="Smiley face" width="65" height="55"  align="left"></a>
                <?if (isset($objResult["DATE_DELIVERED_STORE"]) and isset($objResult["DATE_RETURNED_WHSE"])) {

                   $date_dds = date_create($objResult["DATE_DELIVERED_STORE"]);
                   $date_drtw = date_create($objResult["DATE_RETURNED_WHSE"]);
                   $ddsDiffs = date_diff($date_drtw,$date_dds);
                   $ddsDiff = $ddsDiffs->format("%R%a days");
                    //echo $SLA_DRTW . $drtwDiff;
                      $dds = $objResult["SLA_DDS"]-$ddsDiff;
                        if ($dds>=0) {?><img src="images/like.jpg"  width="16" height="16" title="like"> <?echo abs($dds) . 'day/s'; 
                        }else{?><img src="images/dislike.jpg"  width="16" height="16" title="dislike"> <?echo  abs($dds) . 'day/s'; 
                        }
                }?>
                </td>
            </tr>
            <tr>
                <td>
                    <?if (isset($objResult["ATT_DRQ"])) {?>
                        <a href="<?echo "/RETRACK/imgpdf/" . $objResult["ATT_DRQ"] ?>" download = "<? echo $objResult["ATT_DRQ"]; ?>">Download POD</a>

                    <?}else{?>
                        <label style="font-weight:normal;">No File</label>
                    <?}?>
                </td>
                <td>
                </td>
                <td>
                    <?if (isset($objResult["ATT_DRCW"])) {?>
                        <a href="<?echo '/RETRACK/imgpdf/' . $objResult["ATT_DRCW"]?>" download = "<? echo $objResult["ATT_DRCW"]; ?>">Download Report</a>
                    <?}else{?>
                        <label style="font-weight:normal;">No File</label>
                    <?}?>
                </td>
                <td>
                </td>
                <td>
                    <?if (isset($objResult["ATT_DFSC"])) {?>
                        <a href="<?echo  '/RETRACK/imgpdf/' . $objResult["ATT_DFSC"]?>" download = "<? echo $objResult["ATT_DFSC"]; ?>">Download POD</a>
                    <?}else{?>
                        <label style="font-weight:normal;">No File</label>
                    <?}?>
                </td>
                <td>
                </td>
                <td>
                    <?if (isset($objResult["ATT_DRTW"])) {?>
                        <a href="<?echo '/RETRACK/imgpdf/' . $objResult["ATT_DRTW"]?>" download = "<? echo $objResult["ATT_DRTW"]; ?>">Download Report</a>
                    <?}else{?>
                        <label style="font-weight:normal;">No File</label>
                    <?}?>
                </td>
                <td>
                </td>
                <td>
                    <?if (isset($objResult["ATT_DDS"])) {?>
                        <a href="<?echo '/RETRACK/imgpdf/' . $objResult["ATT_DDS"]?>" download = "<? echo $objResult["ATT_DDS"]; ?>">Download POD</a>
                    <?}else{?>
                        <label style="font-weight:normal;">No File</label>
                    <?}?>
                </td>
            </tr>
            <tr>
                <td>
                    <label>Date Requested</label>
                </td>
                <td>
                </td>
                <td>
                    <label>Received in Whse</label>
                </td>
                <td>
                </td>
                <td>
                    <label>Fwd to Service Center</label>
                </td>
                <td>
                </td>
                <td>
                    <label>Returned in Whse</label>
                </td>
                <td>
                </td>
                <td>
                    <label>Delivered in Store</label>
                </td>
            </tr>
        </table>
        <table>
            <div class="toolbarModal">
                <div class="toolbar-background ">
                </div>
                <div class="toolbar-infoContainer">
                    <label style="text-indent: 10px; font-size:15px ;">Mobile No.:</label> <label style="color:blue;"><?=$objResult["MOBILE"];?></label><br/><br/>

                    <label style = "position: absolute; left:25px;">ASN Type Description</label>
                    <label style = "position: absolute; left:325px;">IMEI No.</label> 
                    <label style = "position: absolute; left:565px;">MTPOS Invoice</label>
                    <label style = "position: absolute; left:805px;">Mybss Case</label>
                    </br>
                    <label style="position: absolute; left:45px; font-size:18px;"><?=$objResult["RETURN_TYPE"];?></label>
                    <label style="position: absolute; left:305px; font-size:18px;"><?=$objResult["IMEI"];?></label>
                    <label style="position: absolute; left:555px; font-size:18px;"><?=$objResult["INVOICE"];?></label>
                    <label style="position: absolute; left:800px; font-size:18px;"><?=$objResult["MYBSS"];?></label><br/><br/>

                    <label style = "position: absolute; left:25px;";>Client/Store Name:</label> 
                    <label style = "position: absolute; left:565px;">Item Description:</label>
                    <br />
                    <label style="position: absolute; left:25px; font-size:18px;"><?=$objResult["CLIENT_STORE"];?></label> 
                    <label style="position: absolute; left:555px; font-size:18px;"><?=$objResult["DESCR"];?></label> <br /><br/>

                    <label style = "text-indent: 10px">Diagnosis:</label>                   
                    <?if (isset($objResult["ATT_DIAGNOSIS"])) {?>
                        <a href="<?echo "/RETRACK/imgpdf/" . $objResult["ATT_DIAGNOSIS"] ?>" download = "<? echo $objResult["ATT_DIAGNOSIS"]; ?>">Download Report</a>

                    <?}else{?>
                        <label style="font-weight:normal;">No File</label>
                    <?}?>
                    <br/>
                    <textarea name="Text1" cols="110" rows="5"  style="text-indent: 20px; font-size:15px ;" readonly="readonly"><?print $objResult["DIAGNOSIS"];?></textarea><br/>
                </div>
            </div>
        </table>


            <!--div id= "displayWindow4"></div-->

          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default"> <a href = "RLLAMES-PC" data-toggle="modal" data-target="#contactus" data-remote="false">Contact Us</a></button>&nbsp;&nbsp;
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          </div>
        </div>
      </div>
    </div>  

<div id="contactus" class="modal fade" role="dialog">
      <div class="modal-dialog">
        <!-- Modal content-->
        <div class="modal-content">
          <div class="modal-header" style="background-color: #333666;">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title">Contact Us</h4>
          </div>
          <div class="modal-body">

        <table>
            <a href="" title=""><img src="images/drq.png" alt="Smiley face" width="65" height="45"  align="left"></a>
            <tr>
              <td><label for="label">Hotline:</label></td>
              <td><label for="label">982-9999</label></td>
            </tr> 
            <tr>
              <td><label for="label">Email:</label></td>
              <td><label for="label"><a href="mailto:support.phi-nsc@dbschenker.com?Subject=Globe%20Retrack" target="_top">support.phi-nsc@dbschenker.com</a></label></td>
            </tr> 
        </table> 
            <div id= "displayWindow9"></div>

          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          </div>
        </div>

      </div>
    </div>
<?  
        }
    //}
//}
?>

错误消息:注意:未定义的索引:第277行的C:\ xampp \ htdocs \ Globe \ retrackView.php中的data1

0 个答案:

没有答案