在输入 HTML 表单上从 Java 脚本传递参数
passing parameter from java script on input html form
我在将javascript变量作为html表单上的输入隐藏类型的值传递时遇到问题。
更多详情 :
public function exportToPdf1($headerText=""){
// serialize the grid object into the session
$_SESSION[$this->viewPaneId."-pdf"] = serialize($this);
$pfdExport .= ' // create the export to pdf button
$("#'.$this->getViewPaneId().'").prepend("<div id='"pdfExport'" style='"float:right; border: none; cursor:pointer;'"><img src='"images/stock_save_pdf.png'"> </div>");';
$pfdExport.=' // onClick function
var printToPdf = false;
var selectedRowId;
$("#pdfExport").click(function(){
selectedRowId = $("#'.$this->getViewPaneId().'input[name=''rowSelectionRadio'']:checked").val();
if(selectedRowId){
if(confirm("Are you sure to print this object ?")){
printToPdf = true;
}
}else{
printToPdf = false;
alert("Please select an element from the table first.");
}
// create a temporarly form, in order to POST the data
$("<form id='"pdf-form'" method='"post'" action='"index.php?c=gridToPdf'"><input type='"hidden'" name='"gridObjId'" value='"'.$this->viewPaneId.''"></form>").appendTo("#rightcolumn");
$("<input type='"hidden'" name='"headerText'" value='"'.$headerText.''">").appendTo("#pdf-form");
$("<input type='"hidden'" name='"act'" value='"exportObject'">").appendTo("#pdf-form");
$("<input type='"hidden'" name='"rId'" value='"'.selectedRowId.''" >").appendTo("#pdf-form");
// submit the form and remove it
$("#pdf-form").submit().remove();
}
});';
始终 rId 获取值字符串 "selectedRowId",而不是 selectedRowId var 的值。
有没有人知道如何处理这个问题?
好吧,selectedRowId
似乎没有定义,selectedRowId
在PHP中也不是有效的变量,这就是为什么输入字段的值selectedRowId
,因为PHP认为它是一个字符串而不是一个变量。
/edit-> okey,我看到selectedRowId
是一个 javascript 变量而不是 php 变量。因此,您需要使用"+"而不是"."进行连接
相关文章:
- 测试mongo脚本中是否存在参数
- 建议将包含不同参数的内联JS转换为外部脚本
- 如何参数化ajax TruClient脚本中的值
- 在GoogleWebApp脚本中,Cant似乎无法将多个参数从JS传递到HTML
- 如何在谷歌电子表格脚本中测试范围参数的类型
- ExternalInterface为我提供了在使用多个参数时停止脚本的选项.为什么?
- 谷歌应用脚本中的 UrlFetchApp.fetch 删除 url 参数
- 将参数传递到外部 JS 脚本的最佳方法
- 传递php字符串作为php脚本中调用的javascript函数的参数
- jQuery脚本,它搜索现有的查询参数并且不添加“"如果存在
- 如何使用参数调用java脚本函数,其中参数来自字符串变量
- Python CGI脚本,我无法通过'+'加号运算符作为参数
- 谷歌电子表格:为带有参数的按钮指定一个脚本
- PHP-如何让别人可以'不要更改url中的参数,也不要在刷新页面时再次运行脚本
- 如何将参数从python脚本传递到html文件并获得输出
- 将命令行参数发送到 npm 脚本
- 如何从批处理文件调用一个带有2个参数的java脚本函数,并将结果返回到环境变量
- JS从内部获取脚本参数
- 打字脚本:参数类型函数不能分配给参数类型函数
- 流星:使外部脚本参数响应