我尝试在jquery的加载函数中更改select的发送值,我用这个
<script>
var value_sel_cat = jQuery('#cat_post').val();
</script>
<?php
print "<select name='anunpost[select_cat_post]' onchange=\"jQuery('#subcats').show(1000).load('index_subcats.php?id='+value_sel_cat)\" class='web_post_input_text' id='cat_post'>";
print "<option value='one'>1</option>";
print "<option value='two'>2</option>";
print "</select>";
?>
这里加载我从脚本调用的文件和index_subcats.php?id,在id中我想在每个onchange中选择select的值:
<div id="subcats">Show hre the id in each onchange of select</div>
但所有时间都告诉我未定的
Thabk's,问候
答案 0 :(得分:0)
试试this.value
print "<select name='anunpost[select_cat_post]' onchange=\"jQuery('#subcats').show(1000).load('index_subcats.php?id='+this.value)\" class='web_post_input_text' id='cat_post'>";
答案 1 :(得分:0)
试试这个:
<script>
jQuery('#cat_post').live('change', function(){
var value_sel_cat = jQuery('#cat_post').val();
jQuery('#subcats').show(1000).load('index_subcats.php?id='+value_sel_cat)
});
</script>
<?php
print "<select name='anunpost[select_cat_post]' class='web_post_input_text' id='cat_post'>";
print "<option value='one'>1</option>";
print "<option value='two'>2</option>";
print "</select>";
?>