获取函数的表单隐藏变量
Get form hidden variables to a function
我知道函数需要使用onclick或任何事件来调用。但是,是否可以在没有用户处理的情况下获得隐藏值。
样品形式:
$ID = 3;
$Report1 = "Test1.docx";
<form id = "Test" action="Nextpage.php">
//Not sure how to call out my function over here...
<input type="hidden" id="ID" name="ID" value="<?php echo $ID ?>"/>
<input type="hidden" id="ReportPath" name="ReportPath" value="<?php echo $ReportPath ?>"/>
//Once user click, function of RemoveDoc() will handle it.
<input type="submit" id="Remove" name="<?php echo $Report1?>" value="Remove" title="Remove report1" onclick="return RemoveDoc(this.name, this.getAttribute('Report1'));" />
我的功能:
function Remove(ID, ReportPath, Report1)
{
xmlhttp1=new XMLHttpRequest();
xmlhttp1.open("GET","functions/call.php?ID="+ID+"&ReportPath="+ReportPath+"&Report1="+Report1,true);
xmlhttp1.onreadystatechange=function()
{
if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
{
document.getElementById("msg").innerHTML= xmlhttp1.responseText;
}
}
xmlhttp1.send();
return false;
}
那么,我如何将输入的隐藏值传递到我的函数Remove(ID,ReportPath…)中呢?因为它现在是隐藏的,没有采取任何操作。请告知。
您只需获得
var id = document.getElementById('ID').value;
var reportpath = document.getElementById('ReportPath').value;
var report1 = document.getElementById('Report1').value;
调用函数:
Remove(id, reportpath, report1);
让事情对你来说更容易。您可以使用jquery。只需将其包含在您的页面中:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<form id="Test" action="Nextpage.php">
<input type="hidden" id="ID" name="ID" value="<?php echo $ID ?>"/>
<input type="hidden" id="ReportPath" name="ReportPath" value="<?php echo $ReportPath ?>"/>
<input type="submit" id="remove" name="<?php echo $Report1?>" value="Remove"/>
</form>
<script>
$('#remove').click(function(){
var id = $('#ID').val();
var reportpath = $('#ReportPath').val();
var report1 = $('#Report1').val(); //check this as I dont see it in your form
//call your function from here
Remove(id, reportpath, report1);
});
//function definition here
function Remove(id, reportpath, report1)...
</script>
相关文章:
- 将值连接到隐藏变量
- 如何隐藏变量
- Javascript显示窗体的隐藏变量
- 如何在使用servlet处理时使用javascript设置隐藏变量的值
- 获取函数的表单隐藏变量
- 获取从函数到 php 的表单隐藏变量
- JavaScript中的隐藏变量,它是如何工作的
- 使用 AJAX 将隐藏变量解析为另一个 jsp 文件
- JSTL:foreach 循环将值设置为隐藏变量始终返回零
- 使用VB访问Javascript中隐藏变量的值
- 通过javascript设置隐藏变量在Wordpress 3.3.1管理插件页面中不起作用
- 元素.隐藏变量可移植性
- 如何从createRange对象中排除隐藏变量
- 试图在onclick中插入PHP变量,以便设置隐藏变量
- 无法在aspx页面中访问javascript中的代码隐藏变量
- 基于隐藏变量的值执行客户端验证
- 如何在jquery中设置隐藏变量的值
- 如何获得ajax返回id隐藏变量..在请求页面
- 在函数内的函数中赋值隐藏变量
- HTML表单隐藏变量不显示在php