Javascript 在函数中传递参数
我想在函数Javascript 在函数中传递参数,javascript,php,jquery,Javascript,Php,Jquery,我想在函数Myfunction()中传递参数。我想在同一个函数中传递1)php值2)this.value3)document.getElementById(“rec”)。 如果我只传递这个.value作为参数函数调用成功并传递到jquery ajax页面,但一次传递三个或两个参数会有问题。如果我尝试使用jquery传递操作,它也不起作用。 document.getElementById(“rec”)和var-eid=$(“#rec”).val()不工作 echo '<form method
Myfunction()
中传递参数。我想在同一个函数中传递1)php值2)this.value
3)document.getElementById(“rec”)
。
如果我只传递这个.value
作为参数函数调用成功并传递到jquery ajax页面,但一次传递三个或两个参数会有问题。如果我尝试使用jquery传递操作,它也不起作用。
document.getElementById(“rec”)
和var-eid=$(“#rec”).val()代码>不工作
echo '<form method="post">';
$rec="select * from recruiter where comp_id='$comp'";
$rec1=mysql_query($rec);
echo '<select class="rec" id="rec" name="e_first_name" style="width:155px;" required onchange="myFunction(this.value);">';
echo '<option value="" selected>Select Recruiter</option>';
while($rfet=mysql_fetch_assoc($rec1))
{
echo '<option value="'.$rfet["e_id"].'">'.$rfet["e_first_name"].'</option>';
}
echo '</select>';
echo '<input type="text" name="dob" style="width:155px;display:none;" id="datepicker1" placeholder="Choose Date" size=18 maxlength=50>';
echo '<select name="report" style="width:155px;" class="report" onchange="myFunction(this.value);">
<option selected> Select Filter</option>
<option value="datz">By Date</option>
<option value="week">By week</option>
<option value="month">By month</option>
</select>';
echo '</form>';
?>
在函数中添加任何参数
例如:
function myFunction(a) {
$("#pre").hide();
var datz=$("#datepicker1").val();
var filt=$(".report").val();
var eid=$("#rec").val();
console.log(a + ' : ' datz + ' : ' + filt + ' : ' + eid);
$.ajax({
type: "POST",
url: "query3.php",
data: { action: eid,filter:filt,datz:datz},
error: function(msg) {
},
success: function(text) {
$(".refresh").html(text);
}
});
}
只需在`myFunction(a){console.log(a);}console.log(a)中添加参数;不返回任何内容。var datz=$(“#datepicker1”).val();var filt=$(“.report”).val()也不起作用我已经更新了答案。这将返回您的所有值。选择按日期按周按月筛选的问题必须是此值我已经这样做了onclick=demo('Open',“$req_id”);在文本框中。在选择框中不可能吗?
function myFunction(a) {
$("#pre").hide();
var datz=$("#datepicker1").val();
var filt=$(".report").val();
var eid=$("#rec").val();
console.log(a + ' : ' datz + ' : ' + filt + ' : ' + eid);
$.ajax({
type: "POST",
url: "query3.php",
data: { action: eid,filter:filt,datz:datz},
error: function(msg) {
},
success: function(text) {
$(".refresh").html(text);
}
});
}