dpa84373 2016-01-27 15:46
浏览 47

使用Ajax和Jquery构建依赖的下拉列表:无法在get_state.php上显示2个php GET变量 - ajax也在发送

I have index.php?WORKORDER_BASE_ID=w21592 -> This is getting the work order number that I entered, that searches the MSSQL DATABASE. I call $_GET['WORKORDER_BASE_ID']; to be used to run other queries to get database results.

I need a dependent drop down. The first drop down runs the query and returns the result and it uses ajax to go to get_state.php. There it's showing up undefined varialbe/index when I try to CALL $_GET['WORKORDER_BASE_ID']; to run the 2nd query and output it in the second dropdown. How can I get around this?

<?php
require_once("dbcontroller.php");
$db_handle = new DBController();
$query ="SELECT DISTINCT R.PART_ID AS PartId, R.PART_ID  +  '  (' +P.DESCRIPTION + ')'  AS PartFull
        FROM REQUIREMENT AS R INNER JOIN PART AS P 
        ON R.PART_ID = P.ID
        WHERE NOT EXISTS (SELECT PART_ID FROM TRACE_PROFILE TP WHERE R.PART_ID=TP.PART_ID) 
        AND  (R.WORKORDER_BASE_ID = '".$_GET["WORKORDER_BASE_ID"]."')";
$results = $db_handle->runQuery($query);
?>
<html>
<head>
<TITLE>jQuery Dependent DropDown List - Countries and States</TITLE>
<head>
<style>
body{width:610px;}
.frmDronpDown {border: 1px solid #F0F0F0;background-color:#C8EEFD;margin: 2px 0px;padding:40px;}
.demoInputBox {padding: 10px;border: #F0F0F0 1px solid;border-radius: 4px;background-color: #FFF;width: 50%;}
.row{padding-bottom:15px;}
</style>
<script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>
<script>
function getState(val) {
    $.ajax({
    type: "GET",
    url: "index.php",
    data:'PartFull='+val,
    success: function(data){
        $("#state-list").html(data);
    }
    });
}

function selectCountry(val) {
$("#search-box").val(val);
$("#suggesstion-box").hide();
}
</script>
</head>
<body>
<? 
ini_set('display_errors',1);
error_reporting(E_ALL);
date_default_timezone_set('America/New_York');
$dateunix = new DateTime();
$dateunix = $dateunix->getTimestamp();
?>
<input type="textarea" name="WORKORDER_BASE_ID" rows="3" cols="5" id="WORKORDER_BASE_ID" value="<?= $_GET["WORKORDER_BASE_ID"];?>" data-theme="f" class="ui-input-text ui-body-f ui-corner-all ui-shadow-inset"   required>
            <input method="get" id="button"   type="submit">
<h5>WORK ORDER ID:</h5><labelh5><center><? echo $_GET["WORKORDER_BASE_ID"];?></center></labelh5> 
<div class="frmDronpDown">
<div class="row">
<label>Partid:</label><br/>
<select name="PartFull" id="partfull-list" class="demoInputBox" onChange="getState(this.value);">
<option value="">Select Part Id:</option>
<?php
foreach($results as $country) {
?>
<option value="<?php echo $country["PartId"]; ?>"><?php echo $country["PartFull"]; ?> </option>
<?php
}
?>
</select>
</div>
<div class="row">
<label>op seq no:</label><br/>
<select name="state" id="state-list" class="demoInputBox">
<option value="">Select Operation Seq. NO</option>
</select>

</div>
</div>


</body>
</html>

get_state.php

     
<!doctype html>
<html>
<head>
<meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0, user-scalable=no" />

    <title>GET STATE </title>
  
  
  


<!-- jQuery  -->  
    <link href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="style.css" />
    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
    <!-- jQuery  -->  
    
    
    </head>
    
    
    <body>
     <input name="WORKORDER_BASE_ID" type="hidden" value="<?= $_GET["WORKORDER_BASE_ID"];?>" />

<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
date_default_timezone_set('America/New_York');
$dateunix = new DateTime();
$dateunix = $dateunix->getTimestamp();

require_once("dbcontroller.php");
$db_handle = new DBController();
if($_GET["PartFull"] != "") { 

    
     echo $wobi;
     echo $_GET['PartFull'];
    
     echo $_GET['WORKORDER_BASE_ID'];
    
    $query ="SELECT DISTINCT R.OPERATION_SEQ_NO AS OSN, '(' + CONVERT(VARCHAR(30), R.OPERATION_SEQ_NO) + ')  ' + O.RESOURCE_ID AS Expr1
FROM OPERATION 
AS O 
INNER JOIN REQUIREMENT AS R 
ON R.OPERATION_SEQ_NO = O.SEQUENCE_NO AND O.WORKORDER_BASE_ID = R.WORKORDER_BASE_ID
 
WHERE (R.WORKORDER_BASE_ID =  '".$_GET['WORKORDER_BASE_ID']."') AND (R.PART_ID = '" . $_GET["PartFull"] . "')";
 
 
    
    
    $results = $db_handle->runQuery($query);
?>
    <option value="">Select Operation Seq. NO 2</option>
<?php
    foreach($results as $state) {
?>
    <option value="<?php echo $state["OSN"]; ?>"><?php echo $state["Expr1"]; ?></option>
<?php
    }
}


?>
</body>
</html>

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 C++使用Gunplot
    • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
    • ¥15 matlab数字图像处理频率域滤波
    • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
    • ¥15 ELGamal和paillier计算效率谁快?
    • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
    • ¥15 Arcgis相交分析无法绘制一个或多个图形
    • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
    • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
    • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)