本文介绍了如何从 SAP Ui5 中的 XML 文件读取 HTML 输入字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是 XML 视图的代码片段,我能够读取 IDName1"但无法读取/写入 HTML 标记中的Name2",它返回未定义.你能帮助我如何访问 HTML 标签中的Name2"吗?
Below is the code snippet of the view in XML, I am able to read the id "Name1" but unable to read/write "Name2" that's in an HTML tag, it returns undefined. Can you help me with how to access the "Name2" that in the HTML tag?
谢谢
sap.ui.getCore().byId("Name1").setValue(oData.FirstName + " " + oData.LastName + ); // sets the value
// Retunrs undefined
sap.ui.getCore().byId("Name2").setValue(oData.FirstName + " " + oData.LastName + ); // Sets no value
<core:FragmentDefinition
xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"
xmlns:l="sap.ui.layout" xmlns:f="sap.ui.layout.form" xmlns="sap.m"
xmlns:html="http://www.w3.org/1999/xhtml">
<Panel class="pnlSearchDate" id="pnlContent">
<html:span class="textcolor">
<html:b>TITLE</html:b>
</html:span>
<html:br />
<HBox alignItems="Center">
<Label class="textcolor" width="300px" text="{i18n>txtName}" />
<Input id="Name1" class="inputbordercolor" editable="false" width="300px"/>
</HBox>
<HBox justifyContent="Center">
<VBox width="100%">
<html:div class="textcolor"
style="font-size: 0.875rem;font-family: Arial,Helvetica,sans-serif;line-height:25px;color:#6a7694;text-align:justify;">
<html:p>
I,
<html:input class="inputEntry" id="Name2"
editable="false"></html:input>
I hereby confirm that I received one session of XXX.
</html:p>
</html:div>
</VBox>
</HBox>
</Panel>
</core:FragmentDefinition>
推荐答案
因为我想访问 HTML Div ID,所以我简单地使用了下面的代码来设置值并且它有效:
Since I want to access the HTML Div ID, I simply used the below code to set the value and it works:
document.getElementById("Name2").value = _fullName;
这篇关于如何从 SAP Ui5 中的 XML 文件读取 HTML 输入字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!