首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在输入html表单上从java脚本传递参数

在输入html表单上从java脚本传递参数
EN

Stack Overflow用户
提问于 2015-01-10 13:14:00
回答 1查看 531关注 0票数 0

在html表单上将javascript变量作为输入隐藏类型的值传递存在问题。

欲知更多详情:

代码语言:javascript
复制
  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变量的值。

有谁知道如何处理这个问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-01-10 13:17:48

嗯,selectedRowId似乎没有定义,selectedRowId在php中也不是有效的变量,这就是为什么输入字段有值selectedRowId,因为php认为它是字符串而不是变量。

/ selectedRowId -> okey,我看到是javascript变量,而不是php变量。因此,您需要使用"+“作为连接,而不是”。和

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27876608

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档