具有讽刺意味的是它正在显示正确的值但不在输入文本框的value属性中;并且文本框中都没有显示任何内容
当我在谷歌浏览器上检查我的网页时 输入标记的代码是
<input name="leave_allowed" class="form-control" id="leave_allowed" value="">15</input>
这里15是我想要的结果,但它应该显示在value属性中 亲切地帮助我
这是我的选择列表,它从db
获取值<span class="span_error"><?echo $error_cmp_id;?></span>
<select name="ddl_ofc" size="1" class="form-control" id="ddl_ofc" onchange="getleaveid(this.value);">
<option value="0" disabled selected=''>Select Leave Type</option>
这是我输入文本框的代码
<div class="form-group">
<label>Leaves Allowed*</label>
<span class="span_error"></span>
<input name="leave_allowed" class="form-control" id="leave_allowed" value="">
</div>
这里是jquery函数
function getleaveid(id)
{
//alert(id);
// $('#leave_allowed').val("Select From the DropDown Above");
$.ajax({
type:"POST",
url:"getdata.php",
data:{leaveid:id},
success:function(data)
{
$('#leave_allowed').val(data);
}
});
}
这是getdata.php文件
function get_total_leaves_allowed($leaveid)
{
$query_leave="SELECT * from leave_type where leave_type_id='$leaveid'";
$result_leave=mysql_query($query_leave);
$rl=mysql_fetch_array($result_leave);
$leaves_allowed=$rl['leave_allowed'];
echo $leaves_allowed;
}
if(isset($_POST['leaveid']))
{
$leaveid =$_POST['leaveid'];
get_total_leaves_allowed($leaveid);
}