Diesem Array Werte zuweisen...
ali
- javascript
Hi!
Also ich habe wie ihr hier seht ein Array (Item). Dieser hat Elemente. Ich habe jetzt die Elemente so verknüpft, dass jeder Array eine TABLE (Tabelle) erzeugt. Ich möchte aber jetzt auf jede Tabelle (jedem Item) einzeln zugreifen, da jede Tabelle an einem anderen Ort positioniert ist. Im Moment sind diese ja untereinander geordnet.
function makeItem() {
var Item = new Array();
Item[0] = ["Startseite", "index.htm", "News", "news.htm"];
Item[1] = ["Auftrag", "auftrag.htm", "Progr. Sprach.", "progr_spr.htm", "Grafikdesign", "grafikdesign.htm"];
Item[2] = ["JS FADE", "js_fade.htm", "JS MENU", "js_menu.htm"];
Item[3] = ["Demovorlagen", "demovorlagen.htm", "Referenzliste", "ueberuns.php/"];
Item[4] = ["Kontaktformular", "impr.php/", "Impressum", "tzpressum.php/"];
for(var i = 0; i < Item.length; i++) {
document.write("<table width="102" bgcolor="" + bgColor + "" cellspacing="0" cellpadding="3" style="border-bottom: 1px solid " + borderColor + "; border-left: 1px solid " + borderColor + "; border-right: 1px solid " + borderColor + ";">");
for(var j = 1; j < Item[i].length; j+=2) {
document.write("<tr><td style="cursor: hand" onMouseOver="this.style.backgroundColor='" + hilightItem + "';" onMouseOut="this.style.backgroundColor='" + normalItem + "';" onClick="window.location.href='" + Item[i][j] + "'"><font face="" + fontFace + "" size="" + fontSize + "" color="" + fontColor + "">" + Item[i][j-1] + "</font></td></tr>");
}
document.write("</table>");
}
}
Zusammengefasst: Ich möchte die schon zu Tabellen verarbeiteten Items einzeln nehmen können, um sie weiter zu bearbeiten.
Bloß wie? Habe schon probiert, vor den document.write Variablen zu setzen, aber irgendwie gings net.
Bitte helft mir. *winzel*
Gruss ali ;)
also:
den <td>s ids zuweisen, also in der art:
document.write("<td id="item2">bla</td>");
und dann alle, die in item[0] drin waren, "item0" nennen usw.
DER ZUGRIFF:
variable=item2.innerHTML;
wenn das nicht läuft, dann
variable=document.all.item2.innerHTML;
und natürlich angleichen.
Wird natürlich schwieriger, wenn in den <td>s noch tags drin stehen... Die weden nämlich mit ausgegeben.
Wenns so nicht läuft, meld dich noch mal.
Yooohooo!! Hab's selber geschafft!
Danke AB, aber mit ID-Tag hat das nichts zu tun gehabt!
Ich weiß aber, dass ich diesen auch noch brauchen werde, aber jetzt hab ich endlich schonmal das automatische Lesen der Werte.
Hier der Quelltext:
<script type="text/javascript">
<!--
// Configuration
bgColor = "#A4A4A4";
borderColor = "#FFFFFF";
fontFace = "Arial";
fontSize = "2";
fontColor = "#6E6E6E";
normalItem = "#A4A4A4";
hilightItem = "#FFFFFF";
// - - - - - - -
function makeItem() {
var Item = new Array();
Item[0] = ["Startseite", "index.htm", "News", "news.htm"];
Item[1] = ["Auftrag", "auftrag.htm", "Progr. Sprach.", "progr_spr.htm", "Grafikdesign", "grafikdesign.htm"];
Item[2] = ["JS FADE", "js_fade.htm", "JS MENU", "js_menu.htm"];
Item[3] = ["Demovorlagen", "demovorlagen.htm", "Referenzliste", "referenzliste.htm"];
Item[4] = ["Kontaktformular", "kontaktformular.htm", "Impressum", "impressum.htm"];
for(var i = 0; i < Item.length; i++) {
Menu = new Array;
Menu[i] = "<table width="102" bgcolor="" + bgColor + "" cellspacing="0" cellpadding="3" style="border-bottom: 1px solid " + borderColor + "; border-left: 1px solid " + borderColor + "; border-right: 1px solid " + borderColor + ";">";
for(var j = 1; j < Item[i].length; j+=2) {
Menu[i] += "<tr><td style="cursor: hand" onMouseOver="this.style.backgroundColor='" + hilightItem + "';" onMouseOut="this.style.backgroundColor='" + normalItem + "';" onClick="window.location.href='" + Item[i][j] + "';"><font face="" + fontFace + "" size="" + fontSize + "" color="" + fontColor + "">" + Item[i][j-1] + "</font></td></tr>";
}
Menu[i] += "</table>";
document.write(Menu[0]); // Wo null steht, kann ich nun eines der oben stehenden ITEMS >EINZELN< auslesem lassen. Sonst standen nämlich immer alle da.
}
}
makeItem();
//-->
</script>
Trotzdem nochmal ein riesengroßes DANKESCHÖN!
Gruss ali ;-))