我在网站上实现了以下代码:
var field_name = ["sys_id","country","calendar_integration","user_password","last_login_time"]
var field_value = ["6816f79cc0a8016401c5a33be04be441","United State","Outlook","Password1","2019-03-19 09:48:41"];
let obj = {};
field_name.forEach((a,i) => obj[a] = field_value[i]);
console.log(obj)
$(document).ready(function() {
$("#type").change(function() {
var val = $(this).val();
if (val == "1") {
$("#size").html("<option value='test'>item1: test 1</option><option value='test2'>item1: test 2</option>");
} else if (val == "2") {
$("#size").html("<option value='test'>item2: test 1</option><option value='test2'>item2: test 2</option>");
} else if (val == "3") {
$("#size").html("<option value='test'>item3: test 1</option><option value='test2'>item3: test 2</option>");
} else if (val == "4") {
$("#size").html("<option value='test'>item4: test 1</option><option value='test2'>item4: test 2</option>");
}
});
});
HTML代码中的PHP部分(来自$ Subcategories_Select)是从MySQL数据库中选择事件类型。
在我的网站上,这是有效的,而且还加载了“预设值”(例如EHBO,水等)。
现在出现了我的问题:我还如何在代码段的Java语言部分中实现此SQL部分?
通过这个,我的意思是:
<select id="type" style="width: 100%" class="form-control">
<option value="1" <?php if ($Incident_Type == '1'){echo 'selected="selected"';} ?>>EHBO</option>
<option value="2" <?php if ($Incident_Type == '2'){echo 'selected="selected"';} ?>>Waterhulpverlening</option>
<option value="3" <?php if ($Incident_Type == '3'){echo 'selected="selected"';} ?>>Persoon</option>
<option value="4" <?php if ($Incident_Type == '4'){echo 'selected="selected"';} ?>>Technisch</option>
</select>
<br />
<select id="size" style="width: 100%" class="form-control">
<?php
if(empty($Incident_Type)){
echo '<option value="" disabled="disabled">- Betreft -</option>';
}
elseif($Incident_Type == '1'){
$Subcategories_Select = mysqli_query($con, "SELECT * FROM `incidents_subcategories` WHERE `Categorie` = '$Incident_Type' ORDER BY `Name` ASC");
?><option value="" disabled="disabled" selected="selected">- Betreft -</option><?php
while($row = $Subcategories_Select->fetch_assoc()) {
?><option value="<?php echo $row['ID']; ?>"><?php echo $row['Name']; ?></option><?php
}
}
?>
</select>
零件等。
谢谢!
蒂姆