Hey, wie kann ich z.B. eine Textbox in einem neu erstellten Tabpanel ansprechen?
Code
<tabbox id="SampleSites" selectedIndex="0">
<tabs onclosetab="alert('close')" closebutton="true"><!-- list of tabs -->
<tab>Sample: 1</tab> <!-- default tab -->
</tabs>
<tabpanels id="samplePanels"><!-- list of contents -->
<tabpanel id="SampleDefaultPanel"><!-- default tab's content -->
<box orient="horizontal" flex="1">
<groupbox id="GeoGroupBox">
<caption id="GeoCaption" label="&GeoCaption.label;" />
<grid>
<columns>
<column id="GeoDescriptionColumn" />
<column id="GeoTextboxColumn" />
</columns>
<rows>
<row>
<description value="&TextboxColumnLabel.description;" />
<hbox align="center">
<textbox id="LabelRow" value="" />
<image id="AddLabel" hidden="false"
tooltiptext="&AddLabel.tooltiptext;" onclick="MegxSamCo.setLabel()"
style="cursor:hand" onmouseover="event.target.style.cursor='pointer'"
onmouseout="event.target.style.cursor='default'" />
</hbox>
</row>
<row>
<description value="&TextboxColumnRegion.description;" />
<hbox align="center"><!--onchange="sampleInfo.setLabel(this.value)" -->
<textbox id="RegionRow" value="" />
<image id="AddRegion" hidden="false"
tooltiptext="&AddRegion.tooltiptext;" onclick="MegxSamCo.setRegion();"
style="cursor:hand" onmouseover="event.target.style.cursor='pointer'"
onmouseout="event.target.style.cursor='default'" />
</hbox>
</row>
<row>
<description value="&TextboxColumnLat.Description;" />
<hbox align="center">
<textbox id="LatRow" value="" />
<image id="AddLat" hidden="false" tooltiptext="&AddLat.tooltiptext;"
onclick="MegxSamCo.setLat()" style="cursor:hand"
onmouseover="event.target.style.cursor='pointer'"
onmouseout="event.target.style.cursor='default'" />
</hbox>
</row>
<row>
<description value="&TextboxColumnLong.Description;" />
<hbox align="center">
<textbox id="LongRow" value="" />
<image id="AddLong" hidden="false" tooltiptext="&AddLong.tooltiptext;"
onclick="MegxSamCo.setLong()" style="cursor:hand"
onmouseover="event.target.style.cursor='pointer'"
onmouseout="event.target.style.cursor='default'" />
</hbox>
</row>
<row>
<description value="&TextboxColumnDepth.Description;" />
<hbox align="center">
<textbox id="DepthRow" value="" />
<image id="AddDepth" hidden="false"
tooltiptext="&AddDepth.tooltiptext;" onclick="MegxSamCo.setDepth()"
style="cursor:hand" onmouseover="event.target.style.cursor='pointer'"
onmouseout="event.target.style.cursor='default'" />
</hbox>
</row>
<row>
<description value="&TextboxColumnMaterial.Description;" />
<hbox align="center">
<textbox id="MaterialRow" value="" />
<image id="AddMaterial" hidden="false"
tooltiptext="&AddMaterial.tooltiptext;" onclick="MegxSamCo.setMat()"
style="cursor:hand" onmouseover="event.target.style.cursor='pointer'"
onmouseout="event.target.style.cursor='default'" />
</hbox>
</row>
</rows>
</grid>
</groupbox>
</box>
</tabpanel>
</tabpanels>
</tabbox>
Alles anzeigen
Das Tabpanel in der Tabbox wird von folgender javascript methode geklont:
Code
var MegxTabCo = new MegxTabController();
function MegxTabController() {
sampleIdPrefix: 'SampleDefaulPanel';
this.createTab = function() {
var tabcount; // number of tabs
var tabbox = document.getElementById("SampleSites");
var tab = document.createElement("tab");
tabcount = tabbox.tabs.childNodes.length;
var serializer = new XMLSerializer();
tabcount = tabcount + 1;
tab.textContent = "Sample: " + tabcount;
tabbox.tabs.appendChild(tab);
var panelcontent = document.getElementById("SampleDefaultPanel");
// todo catch missing panelcontent
var prettyString = XML(serializer.serializeToString(panelcontent))
.toXMLString();
debugHere('pretty:' + prettyString);
var clonePanel = panelcontent.cloneNode(true);
clonePanel.id = '' + tabcount;
var prettyString = XML(serializer.serializeToString(clonePanel))
.toXMLString();
debugHere(this.sampleIdPrefix + ', cloned: ' + prettyString);
panelcontent.parentNode.appendChild(clonePanel);
};
this.removeTab = function() {
var tabbox = document.getElementById("SampleSites");
idx = tabbox.selectedIndex;
debugHere("idx: " + idx);
if (idx <= 0) {
return;
}
tabbox.tabs.removeItemAt(idx);
tabbox.tabpanels.removeChild(tabbox.tabpanels.selectedPanel);
var panels = tabbox.tabpanels.getElementsByTagName("tabpanel");
var myTabs = tabbox.tabs;
for ( var i = 1; i < panels.length; i++) {
var p = panels[i];
var t = myTabs.getItemAtIndex(i);
var j = i + 1;
p.id = this.sampleIdPrefix + '_' + j;
t.textContent = "Sample: " + j;
}
tabbox.selectedIndex = idx - 1;
};
}
Alles anzeigen
Nun möchte ich einen Wert in die textbox des selektierten tabpanels schreiben (z.b. in das dritte panel).
Im folgenden Code versuche ich eine Textbox im selektierten panel anzusprechen, aber es klappt nicht.
Code
this.setSampleValue = function(elementId, value) {
var tabindex = this.getTabIndex();
debugHere("setSampleValue");
if (tabindex == 0){
setTextElementValue(elementId, value);
}
else{
//try {
var tabbox = document.getElementById("SampleSites");
debugHere(tabbox);
var nodes = tabbox.getElementsByAttribute("id", "MaterialRow");
debugHere("nodes:" + nodes);
for (var i = 0; i < nodes.length; ++i) {
var item = nodes[i];
var nodename = item.nodeName;
debugHere("itemname: " + nodename);
var test = "test";
nodename.nodeValue = test.stringValue;
// Calling myNodeList.item(i) isn't necessary in JavaScript
}
}
};
Alles anzeigen
Bei meiner debugausgabe erscheint halt das itemname: textbox sei was ja auch richtig ist. aber es wird nichts in die textbox selbst als value reingeschrieben.
Hat irgendjmd eine Idee?