我需要一些帮助,我一直得到这个错误,我从firebug得到了这个
ReferenceError: ECOFATTYACHID is not defined
getBaseplate(ECOFATTYACHID,this.value)
并且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);
}
}
并且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>
请帮助我,我在这里做错了什么?从第一次下拉和第二次下拉,我做得很好。所以我从第一个下拉列表得到projectName,从第二个下拉列表得到厚度。
答案 0 :(得分:1)
请使用此
<select name="thickness" onchange='getBaseplate("<?php echo $projectName?>",this.value)'>
答案 1 :(得分:0)
更改为
<select name="thickness" onchange="getBaseplate('<?php echo $projectName?>',this.value)">
现在你要传递一个字符串