更改标签标题
问题描述:
我试图从标签更改标题的标题,但它不会更改。我已经调试过了,变量不是null。这里是我的代码:更改标签标题
HTML文件只加载XML和js文件....
这里是我的xml文件:
<?php
<object class="MPage1" name="MPage1" baseclass="MPage">
<property name="DesignConfigName">iPhone - Vertical (320x480)</property>
<property name="DesignConfigWidth">320</property>
<property name="DesignConfigHeight">480</property>
<property name="UseBackground">1</property>
<property name="Animations">a:0:{}</property>
<property name="Background"></property>
<property name="Caption">MPage1</property>
<property name="Font">
<property name="Family">Helvetica, Arial, sans-serif</property>
<property name="Size">16px</property>
</property>
<property name="Height">480</property>
<property name="HiddenFields">a:0:{}</property>
<property name="Name">MPage1</property>
<property name="Width">320</property>
<property name="jsOnAjaxCallComplete">MPage1AjaxCallComplete</property>
<property name="jsOnLoad">MPage1Load</property>
<object class="MButton" name="MButton1" >
<property name="Animations">a:0:{}</property>
<property name="Caption">Teste</property>
<property name="Height">43</property>
<property name="Left">99</property>
<property name="Name">MButton1</property>
<property name="Top">57</property>
<property name="Width">150</property>
<property name="jsOnClick">MButton1Click</property>
</object>
<object class="MLabel" name="MLabel1" >
<property name="Animations">a:0:{}</property>
<property name="Caption">dsadasdsa</property>
<property name="Font">
<property name="Family">Helvetica, Arial, sans-serif</property>
<property name="Size">16px</property>
</property>
<property name="Height">115</property>
<property name="Left">77</property>
<property name="Name">MLabel1</property>
<property name="Top">175</property>
<property name="Width">195</property>
</object>
</object>
?>
,在这里我的javascript:
function showRecords() {
results.text = '';
db.transaction(function(tx) {
tx.executeSql(selectAllStatement, [], function(tx, result) {
dataset = result.rows;
for (var i = 0, item = null; i < dataset.length; i++) {
item = dataset.item(i);
var texto= item['nome'] + ' , ' + item['estoque'];
var areaDeTexto = document.getElementsByName('MLabel1');
areaDeTexto.Caption = texto;
// alert(areaDeTexto.value));
}
});
});
}
答
var areaDeTexto = document.getElementsByName('MLabel1');
areaDeTexto.Caption = texto;
areaDeTexto将是一个集合,您无法为集合设置标题。您需要遍历集合来单独更改标题。 (可能有其他错误。)
新增假设所有东西都正常,则可以通过元素(分别从当前的循环)循环使用:
var areaDeTexto = document.getElementsByName('MLabel1');
for (var j = 0; j < areaDeTexto.length; j++) {
areaDeTexto.Caption = "some caption";
}
,但我在拍这里有很多假设;特别是您可以通过这种方式更改标题。
+0
那我该如何更改标题呢? – shadsauhduisad
这不是有效的PHP。为什么PHP标签中的XML? –
我不知道。我正在使用html5 Builder – shadsauhduisad