我試圖實現與2個選擇標籤和1個輸入(文本)選擇>選擇>文本框(目錄>項目>項目介紹)
的東西我有1個選擇標籤:分類 我有1個選擇標籤: Item and I have 1 input tag:商品描述
它們應該是動態的,所以商品描述只顯示Item中的值,Item僅顯示Category中的值。但我已經使用了2個選擇標記的值來交互,我怎樣才能讓輸入標記顯示響應文本
下面是僅用於前2個選擇標記的示例。輸入的內容應該響應第二個選擇標籤。
$("#select1").change(function() {
if($(this).data('options') == undefined){
/*Taking an array of all options-2 and kind of embedding it on the select1*/
$(this).data('options',$('#select2 option').clone());
}
var id = $(this).val();
var options = $(this).data('options').filter('[value=' + id + ']');
$('#select2').html(options);
});
$("#select1").trigger('change');
與小提琴(例如)http://jsfiddle.net/hW4Mm/3/
我自己的文件有這樣的:
<select name="select1" id="select1">
<?php while ($row = mysqli_fetch_assoc($result1)) {
echo "<option value='" . $row['id_ziektesoort'] . "'" . ">" . $row['naam'] . "</option>";
}
?>
</select>
<label>Incident: </label>
<select name="select2" id="select2">
<?php while ($row = mysqli_fetch_assoc($result2)) {
echo "<option value='" . $row['ziektesoort_id_ziektesoort'] . "'" . ">" . $row['naam'] . "</option>";
}
?>
</select>
<input name="advies" id="advies" type="text" readonly="readonly"><?php while ($row = mysqli_fetch_assoc($result3)) {
echo $row['advies'];
}?>
</input>
你要輸入要顯示的內容? (有反應是不足以說的) – marekful
只是在文本中的描述 – shgzon
是的,但是描述在哪裏? – marekful