我正在设计连接到oracle DB的三重下拉列表。当用户选择3个值时,它必须将值更新为db。但我有问题,第三个下拉列表没有显示在print_r,这意味着我不能把第三个值放在数据库中
这是该计划的JS,
function getThickness(projectName) {
var strURL="findThickness.php?project="+projectName;
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
document.getElementById("thicknessDiv").innerHTML=req.responseText;
document.getElementById("baseplateDiv").innerHTML='<select name="baseplate">'+
'<option>Select Baseplate</option>'+'</select>';
} else {
alert("Problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
function getBaseplate(projectName,thicknessVal) {
var strURL="findBaseplate.php?project="+projectName+"&thicknessValue="+thicknessVal;
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
document.getElementById("baseplateDiv").innerHTML=req.responseText;
} else {
alert("Problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
和findThickness.php,
<?php
$projectName = strval($_GET['project']);
$query = "SELECT DISTINCT THICKNESS FROM COMPONENT_CUTTING WHERE PROJECT_NAME = :projectName";
$result = oci_parse($conn, $query);
oci_bind_by_name($result, ":projectName", $projectName);
oci_execute($result);
?>
<select name="thickness" onChange="getBaseplate('<?php echo $projectName?>',(this.value));">
<option>Select Thickness</option>
<?php while ($row = oci_fetch_array($result, OCI_BOTH)) { ?>
<option value=<?php echo $row['THICKNESS']?>><?php echo $row['THICKNESS']?></option>
<?php } ?>
</select>
和findBasePlate.php就像这样
<?php
$projectName = strval($_GET['project']);
$thicknessValue = intval($_GET['thicknessValue']);
$query = "SELECT BASE_PLATE FROM COMPONENT_CUTTING WHERE THICKNESS = :thicknessVal AND PROJECT_NAME = :projectName";
$result = oci_parse($conn, $query);
oci_bind_by_name($result, ":projectName", $projectName);
oci_bind_by_name($result, ":thicknessVal", $thicknessValue);
oci_execute($result);
?>
<select name="baseplate">
<option>Select Baseplate</option>
<?php
while($row = oci_fetch_array($result, OCI_BOTH)) { ?>
<option value><?php echo $row['BASE_PLATE']?></option>
<?php } ?>
</select>
并在用户点击提交时调用的save.php中显示一个print_r,该值显示该值,并且显示如下所示,
Array ( [projectName] => ECOFATTYACHID [thickness] => 28 [baseplate] => [quantityToCut] => 4 [text_remarks] => [submit] => Submit Request )
我不知道我的代码有什么问题。所以请告诉我这个,我非常感谢你们帮助
答案 0 :(得分:2)
请将其放在引号<option value=<?php echo $row['THICKNESS']?>>
中
例如<option value="<?php echo $row['THICKNESS']?>">
它将被解释为<option value=option_xxx>
,并且可能无法给出预期的结果。
您还需要将<option value><?php echo $row['BASE_PLATE']?></option>
更改为<option><?php echo $row['BASE_PLATE']?></option>
删除value