我的代码中是什么导致打印的代码出现在下一行?
function GetSelected (selectTag) {
var selIndexes = "";
for (var i = 0; i < selectTag.options.length; i++) {
var optionTag = selectTag.options[i];
if (optionTag.selected) {
if (selIndexes.length > 0)
selIndexes += "";
selIndexes = optionTag.value;
}
}
var info = document.getElementById ("info");
if (selIndexes.length > 0) {
info.innerHTML = selIndexes;
}
else {
info.innerHTML = "There is no selected option";
}
}
这是组合框中的选项之一:
<select option="single" name= "viocat" id="viocat" onchange="GetSelected (this);" class = "form-control">
<option>Choose category ...</option>
<option value="<?php
$con = mysqli_connect("///") or die (mysql_error());
$sql = mysqli_query ($con, "SELECT violationcategory, MAX(code) AS highest_id FROM tbl_violation where violationcategory = '\r\n DL'");
$sql = "SELECT violationcategory, MAX(code) AS highest_id FROM tbl_violation where violationcategory = '\r\n OR'";
$result = mysql_query ($sql,$con);
while($row = mysql_fetch_array($result)){
$i = $row['highest_id'];
$i++;
echo "OR - " .$i;
}
?> "> Driver's License Related</option>
</select>
此处显示的位置:
<label type= "text" id="info" name="viocode" class = "form-control">
答案 0 :(得分:0)
我不确定下一行的确切含义,但是,从您删除的部分问题来看,我认为这是因为您在新行上启动了PHP块。 而不是:
<option>Choose category ...</option>
<option value="
<?php
尝试:
<option>Choose category ...</option>
<option value="<?php