Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/441.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 混合批处理/jscript/hta:读取jscript中的2个输入并将其传递给批处理_Javascript_Html_Batch File_Jscript_Hta - Fatal编程技术网

Javascript 混合批处理/jscript/hta:读取jscript中的2个输入并将其传递给批处理

Javascript 混合批处理/jscript/hta:读取jscript中的2个输入并将其传递给批处理,javascript,html,batch-file,jscript,hta,Javascript,Html,Batch File,Jscript,Hta,大家早上好 我目前正在编写一个小批量/jscript/hta程序 在下面的程序中,我读取一个文本输入字段,将文本传递给批处理并在其中显示: <!-- :: Batch section @echo off setlocal for /F "delims=" %%a in ('mshta.exe "%~F0"') do set "result=%%a" echo End of HTA window, reply: "%result%" pause goto :EOF --> <

大家早上好

我目前正在编写一个小批量/jscript/hta程序

在下面的程序中,我读取一个文本输入字段,将文本传递给批处理并在其中显示:

<!-- :: Batch section
@echo off
setlocal

for /F "delims=" %%a in ('mshta.exe "%~F0"') do set "result=%%a"
echo End of HTA window, reply: "%result%"
pause
goto :EOF
-->


<HTML>
<HEAD>
<HTA:APPLICATION SCROLL="no" SYSMENU="no" >

<TITLE>HTA Buttons</TITLE>
<SCRIPT language="JavaScript">
window.resizeTo(374,400);

function myFunction() {
  var x = document.getElementById("myText").value;  
  var fso = new ActiveXObject("Scripting.FileSystemObject");
  fso.GetStandardStream(1).WriteLine(x);
  window.close();
}

</SCRIPT>
</HEAD>
<BODY>
   <h3>A demonstration of how to access a Text Field</h3>

    <input type="text" id="myText" value="0123">

    <p>Click the "Login" button to get the text in the text field.</p>

    <button onclick="myFunction()">Login</button>

</BODY>
</HTML>

HTA按钮
窗口。resizeTo(374400);
函数myFunction(){
var x=document.getElementById(“myText”).value;
var fso=新的ActiveXObject(“Scripting.FileSystemObject”);
fso.GetStandardStream(1)、WriteLine(x);
window.close();
}
演示如何访问文本字段
单击“登录”按钮以获取文本字段中的文本

登录
那很好

现在我的问题是: 如何读取两个文本输入字段并将其传递给批处理? 我总是在Jscript部分出错


提前感谢,我希望有人能帮助我。

如果您需要返回多个值,最简单的方法是使用分隔符将它们连接起来,并正确配置/f的
以将读取行拆分为单独的标记

<!-- :: Batch section
@echo off
    setlocal enableextensions disabledelayedexpansion

    rem Defined which tokens we need and the delimiter between them
    for /F "tokens=1,2 delims=|" %%a in ('mshta.exe "%~F0"') do (
        set "field1=%%a"
        set "field2=%%b"
    )

    echo End of HTA window, reply: "%field1%" "%field2%"
    pause
    goto :EOF
-->
<HTML><HEAD><HTA:APPLICATION SCROLL="no" SYSMENU="no" >
<TITLE>HTA Buttons</TITLE>
<SCRIPT language="JavaScript">
    window.resizeTo(374,400);

    function myFunction() {
        new ActiveXObject("Scripting.FileSystemObject")
            .GetStandardStream(1)
            .WriteLine(
                [ // Array of elements to return joined with the delimiter
                      document.getElementById("myText").value
                    , document.getElementById("myText2").value
                ].join('|')
            );
        window.close();
    };
</SCRIPT>
</HEAD>
<BODY>
   <h3>A demonstration of how to access a Text Field</h3>
    <input type="text" id="myText"  value="0123">
    <input type="text" id="myText2" value="4567">
    <p>Click the "Login" button to get the text in the text field.</p>
    <button onclick="myFunction()">Login</button>
</BODY>
</HTML>

HTA按钮
窗口。resizeTo(374400);
函数myFunction(){
新的ActiveXObject(“Scripting.FileSystemObject”)
.GetStandardStream(1)
WriteLine先生(
[//要返回的元素数组与分隔符连接
document.getElementById(“myText”).value
,document.getElementById(“myText2”).value
].join(“|”)
);
window.close();
};
演示如何访问文本字段
单击“登录”按钮以获取文本字段中的文本

登录
太好了,非常感谢!我对“GetStandardStream(1.WriteLine)”的调用是错误的!