TOM: Lösung

Beitrag lesen

<!--

Da ich sehr wenig von Js kenn wende ich mich an euch. Das wisst ihr sicher. Also folgendes Problem:
Wenn ich auf ein Zelle klicke, dass der Inhalt der Zelle in eine Variable kopiert wird und, wenn ich d

ann auf eine andere Zelle in einer anderen Tabelle klicke, dass der Inhalt dort rein kommt. Und das in einer
Textarea der Quelltext geändert wird, von der zuänderden Tabelle.

Danke für eure Hilfe

-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Fuers forum</title>
<script type="text/javascript">
<!--
var data = '';
var byid = false;
var docall = false;
var doclay = false;
function init(){
if(document.getElementById) this.byid = true;
            else{
                 if(document.all && !document.getElementById) {this.byid = false; this.docall = true;
                 }else{ if(document.layers) this.doclay = true;
                       else alert('Fehler beim DOM - Modell!\n\nBitte an den Programmierer wenden!\n(Thomas.Kagerer@erl11.siemens.de oder Webmaster@ngwebdesign.de)');
                 }
            }
updatetxt();
}
function copyInhalt(Name){
if (this.docall && !this.byid)
             this.data = document.all[Name].innerHTML;
          else if (this.byid)
             this.data = document.getElementById(Name).innerHTML;
             else if(this.doclay)
                  this.data = document[Name].innerHTML;
}
function pasteInhalt(Name){
if (this.docall && !this.byid)
             document.all[Name].innerHTML = this.data;
          else if (this.byid)
             document.getElementById(Name).innerHTML = this.data;
             else if(this.doclay)
                  document[Name].innerHTML = this.data;
updatetxt();
}
function updatetxt(){
var data = '';
var Name = 'table2';
if (this.docall && !this.byid)
             data = document.all[Name].innerHTML;
          else if (this.byid)
             data = document.getElementById(Name).innerHTML;
             else if(this.doclay)
                  data = document[Name].innerHTML;
document.form.code.value=data;
}
//-->
</script>
</head>
<body onload="init();">
<form name="form" action="index.html" method="get">
<textarea name="code" rows="20" cols="50"></textarea>

<table style="border: 1px solid black;">
   <tr>
   <td>
     <div id="td1" style="width:30px; height:20px; border: 1px solid red;" onclick="Javascript:copyInhalt('td1');">
     blablabla</div>
   </td>
   </tr>
   </table>
<table style="border: 1px solid black;" id="table2">
   <tr>
   <td>
     <div id="td2" style="width:30px; height:20px; border: 1px solid red;" onclick="Javascript:pasteInhalt('td2');">
     dumdidum</div>
   </td>
   </tr>
   </table>
</form>
</body>
</html>

Das war die Lösung gg

den REst kannste selbst oder?

*puu*

gg