我想在 PHP if 中加入一些 JavaScript。如下所示。但是我不能让它正常工作,建议?
if ($_option->getTitle() == 'Condition') {
'<script language="javascript">
function displayCondition() {
condition = new Array("Please Select a Condition.","<b>Perfect:</b> Text to explain perfect condition!", "<b>Excellent:</b> Text to explain excellent condition!", "<b>Good:</b> Text to explain good condition!", "<b>Poor:</b> Text to explain poor condition!", "<b>Broken:</b> Text to explain broken condition!");
var getsel = document.getElementById(\'select_'.$_option->getId().'\').value;
document.getElementById("divId").innerHTML = condition[getsel];
}
</script>';
$extraParams .= ' onchange="opConfig.reloadPrice();displayCondition();"';
} else if
($_option->getTitle() == 'Original Packaging') {
$extraParams .= ' onchange="opConfig.reloadPrice();Select(select_'.$_option->getId().',\'divShow\',2);"';
} else {
$extraParams .= ' onchange="opConfig.reloadPrice();"';
}