繁体   English   中英

从输入文本中获取价值?

[英]Get value from input text?

我想编写一个省略输入文本字段值的 HTA JScript,当按下回车按钮时,会执行 callShellApplication(结合 echo 命令的值和输入文本字段的值)。

这是我已经拥有的代码片段:

<label for="uname">Command: </label>
    <input type="text" style="color:black; id="command" name="name" required size="20"
           pattern="[a-z]{4,8}">
    <button onclick="callShellApplication('cmd /d /c echo/ &[The value of the text field should be entered here]')">Enter</button>

我可以在那里做什么?

最好的问候, jcjms

您可以使用子进程模块 api 直接调用 shell 脚本(节点 js 后端 js)

例如。

var exec = require('child_process').exec, child;

child = exec('cat *.js bad_file | wc -l',
    function (error, stdout, stderr) {
        console.log('stdout: ' + stdout);
        console.log('stderr: ' + stderr);
        if (error !== null) {
             console.log('exec error: ' + error);
        }
    });
 child();

您可以根据需要自定义此代码

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM