简体   繁体   English

使用 Excel VBA 从 javascript 中的文本框中获取值

[英]Getting a value from a textbox in javascript with Excel VBA

I have a problem with a Macro in Excel, I want to return the value of an "input type="text"" in a javascript webpage, but the value isn't specified in the code (value=""), and it never changes, even when the webpage shows a text in the textbox (The webpage "prints" a text in this textbox, it's not an input by the user).我在 Excel 中的宏有问题,我想在 javascript 网页中返回“input type="text"” 的值,但代码中未指定该值 (value=""),并且它永远不会改变,即使网页在文本框中显示文本(网页在此文本框中“打印”文本,这不是用户的输入)。

Using "IE.Document.getElementById("lat_txt_velmaxima").Value", returns Null.

The code on the page is:页面上的代码是:

class="campo txt_velmaxima"> <label for="lat_txt_velmaxima">Velocidade máxima:</label> 

<input type="text" name="lat_txt_velmaxima" id="lat_txt_velmaxima"
disabled="disabled" value="" readonly="readonly" />

If I'm understanding your question correctly, you just need to grab the value of that readonly text input.如果我正确理解您的问题,您只需要获取该只读文本输入的值。

If that's the case, the right way to query the DOM API through JavaScript is the following:如果是这种情况,通过 JavaScript 查询 DOM API 的正确方法如下:

document.getElementById('lat_txt_velmaxima').value;

Note the lowercase d in document , and lowercase v in value .注意document的小写 d 和value小写 v。

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

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