doudaotui4297 2016-08-15 05:52
浏览 20

在php中获取javascript部分/变量

I have a function like this :

<script>
    function scanToLocalDisk() {

        scanner.scan(displayResponseOnPage,
            {
                "output_settings": [
                    {
                        "type": "save",
                        "format": "pdf",
                        "save_path": "C:\\xampp\\htdocs\\phps\\scanner\\${TMS}${EXT}"
                    }
                ]
            }
        );
    }

    function displayResponseOnPage(successful, mesg, response) {
        if(!successful) { // On error
            document.getElementById('response').innerHTML = 'Failed: ' + mesg;
            return;
        }

        if(successful && mesg != null && mesg.toLowerCase().indexOf('user cancel') >= 0) { // User cancelled.
            document.getElementById('response').innerHTML = 'User cancelled';
            return;
        }

        document.getElementById('response').innerHTML = scanner.getSaveResponse(response);
    }
</script>

and html like this :

<form class='form-horizontal' role='form' action="../proses/tambahtamu.php" method="POST" >    
    <button type="button" onclick="scanToLocalDisk();">Scan</button>
    <div id="response" ></div>
    <button type="submit">Tambah Tamu</button>
</form>

What I wanna ask is; How do I get the "save_path": "C:\xampp\htdocs\phps\scanner\${TMS}${EXT}" with PHP to use for adding to database?

  • 写回答

1条回答 默认 最新

  • dongliyun3301 2016-08-15 06:16
    关注

    You can add hidden field in form like this

     <input id="save_path" type="hidden" name="save_path" value="" />
    

    in scanToLocalDisk function add variable

    var savePath = "C:\\xampp\\htdocs\\phps\\scanner\\${TMS}${EXT}";
    
    document.getElementById("save_path").value = savePath;
    

    when your form will be post then you will get full path in $_POST["save_path"] variable.

    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用