任何人都可以解釋我如何選擇窗體標記中的值並使用PHP而不是實際的值參數?HTML窗體:如何獲得選定的選項不在PHP中的值
例如
<option value="#NOT THIS#">#THIS!#</option>
感謝
任何人都可以解釋我如何選擇窗體標記中的值並使用PHP而不是實際的值參數?HTML窗體:如何獲得選定的選項不在PHP中的值
例如
<option value="#NOT THIS#">#THIS!#</option>
感謝
<script>
$("#yourdropdownid option:selected").text();
</script>
如果這不會爲你工作,試試這個:
<script>
$('#yourdropdownid').find('option:selected').text();
</script>
<select name="select" >
<option value='1'>This 1</option>
<option value='2'>this 2</option>
</select>
和腳本
$(function(){
$("select[name='select']").change(function(){
alert($(this).find('option:selected').text());
});
});
嘗試用 這個。這很簡單。你可以用id="someName"
選擇選項,focuse它的話就像你把(#此!#「)。
<script>
$("#someID").change(function(element) {
var selectedValue = this.options[this.selectedIndex].text;
if (selectedValue === "#THIS!#") {
// do something
}
});
</script>
那麼你不能使用PHP進去選項標記的值。當表單提交它只發送選擇框的值屬性到服務器
由父dom選擇名稱 –
取決於你用什麼來解析HTML – apokryfos
你沒有提到你是否可以使用客戶端代碼來解決這個問題,在這種情況下,你有很多的解決方案,如果你嚴格使用PHP,那麼它依賴於它是否填充選擇值?然後它只是存儲列表並獲取人類友好值的問題。 – Max