Ich möchte gerne das wenn ich in der rechten Spalte auf copy gehe, das links davon im Feld das in der Zwischenablage kopiert wird

  • JavaScript

Es gibt 18 Antworten in diesem Thema. Der letzte Beitrag () ist von Snipy26.

    Ich möchte gerne das wenn ich in der rechten Spalte auf copy gehe, das links davon im Feld das in der Zwischenablage kopiert wird

    Hallo @ All

    kann man hier auch Anfragen stellen für html Codierung? Bin dabei eine private Seite für die Arbeit zu machen, wo ich verschiedene Themen habe.
    Und die besteht aus einer Tabelle mit 3 Spalten und 5 Zeilen. Ich mache hier mal ein Beispiel

    subject Hoch
    prio. Normal
    anliegen. Frage. Copy
    lösung. Lösung. Copy
    intern. Intern. Copy

    zurück


    so im groben schaut es aus. Ich möchte gerne das wenn ich in der rechten Spalte auf copy gehe, das links davon im Feld das in der Zwischenablage kopiert wird, damit ich es in einem anderen program einfügen kann. Beim normalen kopieren passiert es mir leider sehr oft, das ich zusätzlich zwei leerspalten im Text habe. Und bei langen Texten ist das doof.

    Liebe Grüße

    *Titel und Label angepasst*
    Grüße Snipy26



    Auf jeder Aktion erfolgt immer eine Re-Aktion, und selbst wenn es nur ne Fehlermeldung ist. :thumbsup:

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Marcus Gräfe“ ()

    Mit HTML geht sowas nicht, nur mit Javascript.

    Zeig mal deinen HTML-Code, dann kann man das JS dazu basteln. Oder du machst es selbst, hier ein Beispiel: w3schools.com/howto/howto_js_copy_clipboard.asp
    Besucht auch mein anderes Forum:
    Das Amateurfilm-Forum
    Der link ist gut. Bin schon mal ein Ende weiter. Muss nur noch das mit Input lösen. Weil aktuell macht er grad ein extra Kästchen rein. ‍♂️
    Grüße Snipy26



    Auf jeder Aktion erfolgt immer eine Re-Aktion, und selbst wenn es nur ne Fehlermeldung ist. :thumbsup:
    Hier mal der Code:

    Problem ist, wenn ich den Button oben oder unten klicke, kopiert er nur das unten.

    er soll aber das links davon kopieren. als beispiel: was willst du
    das kästchen soll aber nicht da sein


    HTML-Quellcode

    1. <!DOCTYPE html>
    2. <html>
    3. <head>
    4. <meta http-equiv="content-type" content="text/html; charset=windows-1252"/>
    5. <title></title>
    6. <meta name="generator" content="LibreOffice 6.1.4.2 (Windows)"/>
    7. <meta name="created" content="00:00:00"/>
    8. <meta name="changed" content="2019-02-09T21:10:29.539000000"/>
    9. <link href="style.css" rel="stylesheet" />
    10. <style type="text/css">
    11. @page { margin: 2cm }
    12. p.normal { margin-bottom: 0cm; color: #000000; font-family: "Times New Roman"; font-size: 10pt; font-weight: normal }
    13. a:link { color: #0000ff }
    14. a:visited { color: #800080 }
    15. </style>
    16. </head>
    17. <body lang="de-DE" vlink="#800080" dir="ltr"><p class="normal" style="margin-bottom: 0.5cm">
    18. <font color="#f10d0c"><span style="text-decoration: none"><font face="Comic Sans MS"><font size="4" style="font-size: 14pt">#
    19. </font></font></span></font><font color="#f10d0c"><span style="text-decoration: none"><font face="Comic Sans MS"><font size="4" style="font-size: 14pt">Test
    20. Blanko Tabelle</font></font></span></font></p>
    21. <p class="normal" style="margin-bottom: 0.5cm"><br/>
    22. <br/>
    23. </p>
    24. <table width="888" cellpadding="4" cellspacing="1" style="page-break-inside: avoid">
    25. <col width="281"/>
    26. <col width="505"/>
    27. <col width="72"/>
    28. <tr valign="top">
    29. <td width="281" style="border-top: 1px double #808080; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0.1cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p class="normal" align="left">
    30. <font face="Arial"><font size="3" style="font-size: 12pt"><font color =#01DF3A>Subject:</font></font></font></p>
    31. </td>
    32. <td width="505" style="border-top: 1px double #808080; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0.1cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p>
    33. <br/>
    34. </p>
    35. </td>
    36. <td width="72" style="border: 1px double #808080; padding: 0.1cm"><p align="center">
    37. <br/>
    38. </p>
    39. </td>
    40. </tr>
    41. <tr valign="top">
    42. <td width="281" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p class="normal" align="left">
    43. <font face="Arial"><font size="3" style="font-size: 12pt"><font color =#01DF3A>Prio:</font></font></font></p>
    44. </td>
    45. <td width="505" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p>
    46. <br/>
    47. </p>
    48. </td>
    49. <td width="72" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: 1px double #808080; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm"><p align="center">
    50. <br/>
    51. </p>
    52. </td>
    53. </tr>
    54. <tr valign="top">
    55. <td width="281" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p class="normal" align="left">
    56. <font face="Arial"><font size="3" style="font-size: 12pt"><font color =#01DF3A>Anliegen:</font></font></font></p>
    57. </td>
    58. <td width="505" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p>
    59. <br/>
    60. <input type="text" value="Oben" id="myInput1">
    61. <font face="Arial, sans-serif"><font size="3" style="font-size: 12pt">-
    62. was willst du</font></font>
    63. </p>
    64. </td>
    65. <td width="72" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: 1px double #808080; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm"><p class="normal" align="center">
    66. <button onclick="myFunction()">oben</button>
    67. <script>
    68. function myFunction() {
    69. // Get the text field
    70. var copyText = document.getElementById("myInput1");
    71. // Select the text field
    72. copyText.select();
    73. copyText.setSelectionRange(0, 99999); // For mobile devices
    74. // Copy the text inside the text field
    75. navigator.clipboard.writeText(copyText.value);
    76. // Alert the copied text
    77. alert("Copied the text: " + copyText.value);
    78. }
    79. </script>
    80. </p>
    81. </td>
    82. </tr>
    83. <tr valign="top">
    84. <td width="281" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p class="normal" align="left">
    85. <font face="Arial"><font size="3" style="font-size: 12pt"><font color =#01DF3A>L&ouml;sung:</font></font></font></p>
    86. </td>
    87. <td width="505" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p>
    88. <br/>
    89. <input type="text" value="mitte" id="btncopytext">
    90. <id="btncopytext">
    91. <font face="Arial, sans-serif"><font size="3" style="font-size: 12pt">-
    92. da hast du
    93. </font></font>
    94. </p>
    95. </td>
    96. <td width="72" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: 1px double #808080; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm"><p class="normal" align="center">
    97. <button onclick="myFunction()">mitte</button>
    98. <script>
    99. function myFunction() {
    100. // Get the text field
    101. var copyText = document.getElementById("btncopytext");
    102. // Select the text field
    103. copyText.select();
    104. copyText.setSelectionRange(0, 99999); // For mobile devices
    105. // Copy the text inside the text field
    106. navigator.clipboard.writeText(copyText.value);
    107. // Alert the copied text
    108. alert("Copied the text: " + copyText.value);
    109. }
    110. </script>
    111. </p>
    112. </td>
    113. </tr>
    114. <tr valign="top">
    115. <td width="281" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p class="normal" align="left">
    116. <font face="Arial"><font size="3" style="font-size: 12pt"><font color =#01DF3A>Interner
    117. Vermerk:</font></font></font></p>
    118. </td>
    119. <td width="505" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p>
    120. <br/>
    121. <input type="text" value="Unten" id="myInput3">
    122. <font face="Arial, sans-serif"><font size="3" style="font-size: 12pt">- bekommt nix</font></font>
    123. </p>
    124. </td>
    125. <td width="72" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: 1px double #808080; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm"><p class="normal" align="center">
    126. <button onclick="myFunction()">unten</button>
    127. <script>
    128. function myFunction() {
    129. // Get the text field
    130. var copyText = document.getElementById("myInput3");
    131. // Select the text field
    132. copyText.select();
    133. copyText.setSelectionRange(0, 99999); // For mobile devices
    134. // Copy the text inside the text field
    135. navigator.clipboard.writeText(copyText.value);
    136. // Alert the copied text
    137. alert("Copied the text: " + copyText.value);
    138. }
    139. </script>
    140. </p>
    141. </td>
    142. </tr>
    143. </table>
    144. <p class="normal" style="margin-bottom: 0.5cm">&nbsp;</p>
    145. <p class="normal" style="margin-bottom: 0.5cm"><a href="Textbausteine1.htm"><button>Zur&uuml;ck</button></a></p>
    146. </body>
    147. </html>
    Grüße Snipy26



    Auf jeder Aktion erfolgt immer eine Re-Aktion, und selbst wenn es nur ne Fehlermeldung ist. :thumbsup:
    Du kannst nicht 3 gleichnamige Funktionen haben, und Overloading gibt's in JavaScript afaik auch nicht (kein natives jedenfalls, es existieren aber workarounds).

    Bau dir einen Event Listener für OnClick, foreache alle Elemente die eine bestimmte Klasse haben (zB "copyme") und schreib dort dann den Code rein, also in etwa das was in deiner myFunction() steht. Wenn das Kopieren von einem anderen Element aus erfolgen soll (so verstehe ich deine Anforderung) kannst du das auch machen, am besten indem du im Element über ein data Attribut einen Selektor für das Zielelement hinterlegst.

    Siehe daily-dev-tips.com/posts/vanil…ner-on-multiple-elements/


    Link
    Hello World
    Natürlich wäre es besser und ordentlicher, das so zu machen, wie von @Link vorgeschlagen, aber die einfachste Möglichkeit, um den vorhandenen Code nur minimal anpassen zu müssen, wäre folgendes:

    Ersetze

    HTML-Quellcode

    1. <button onclick="myFunction()">oben</button>

    durch

    HTML-Quellcode

    1. <button onclick="myFunction('myInput1')">oben</button>

    (natürlich musst du 3 verschiedene Aufrufe machen, nicht immer mit myInput1)

    JavaScript-Quellcode

    1. function myFunction() {

    durch

    JavaScript-Quellcode

    1. function myFunction(id) {


    und

    JavaScript-Quellcode

    1. var copyText = document.getElementById("myInput1");

    durch

    JavaScript-Quellcode

    1. var copyText = document.getElementById(id);

    Ungetestet!
    Besucht auch mein anderes Forum:
    Das Amateurfilm-Forum
    Hab es mal gemacht, ohne erfolg. er kopiert den garnichts mehr

    hier mal der neue code

    HTML-Quellcode

    1. <tr valign="top">
    2. <td width="281" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p class="normal" align="left">
    3. <font face="Arial"><font size="3" style="font-size: 12pt"><font color =#01DF3A>Anliegen:</font></font></font></p>
    4. </td>
    5. <td width="505" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p>
    6. <br/>
    7. <input type="text" value="Oben" id="myInput1">
    8. <font face="Arial, sans-serif"><font size="3" style="font-size: 12pt">-
    9. was willst du</font></font>
    10. </p>
    11. </td>
    12. <td width="75" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: 1px double #808080; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm"><p class="normal" align="center">
    13. <button onclick="myFunction("myInput1")" button class="btn danger">Oben</button>
    14. <script>
    15. function myFunction(id) {
    16. // Get the text field
    17. var copyText = document.getElementById(id);
    18. // Select the text field
    19. copyText.select();
    20. copyText.setSelectionRange(0, 99999); // For mobile devices
    21. // Copy the text inside the text field
    22. navigator.clipboard.writeText(copyText.value);
    23. // Alert the copied text
    24. alert("Anliegen ist kopiert. : " + copyText.value);
    25. }
    26. </script>
    27. </p>
    28. </td>
    29. </tr>


    beim alten code ging es halbwegs.

    ziel ist, das das was link von oben steht, in der mittleren spalte auf der gleichen zeile es in zwischnspeicher koppiert. was im bild schwarzer text ist. das kästchen davor soll nicht sein. irgendwie muss ich von spalte 3 eine verlinkung zu spalte 2 schaffen. zumindest so mein gedanke.

    sry falls ich mich doof ausgedrückt habe.
    Bilder
    • Test blanko.JPG

      83,67 kB, 961×592, 52 mal angesehen
    Grüße Snipy26



    Auf jeder Aktion erfolgt immer eine Re-Aktion, und selbst wenn es nur ne Fehlermeldung ist. :thumbsup:
    Statt "myFunction("myInput1")" musst du "myFunction('myInput1')" machen. Es ist doch klar, dass du dieselben Anführungszeichen nicht ohne Maskierung verwenden kannst, ist doch in jeder Programmiersprache so.
    Besucht auch mein anderes Forum:
    Das Amateurfilm-Forum
    Hab ich gemacht. aber denn kopiert er nur die letzte zeile.

    siehe bild
    Bilder
    • test blanko 2.JPG

      58,97 kB, 946×596, 48 mal angesehen
    Grüße Snipy26



    Auf jeder Aktion erfolgt immer eine Re-Aktion, und selbst wenn es nur ne Fehlermeldung ist. :thumbsup:
    Ich weiß nicht ob ich dein Problem verstanden habe. Du willst also, dass wenn man "oben" drückt, der Text aus der Textbox links daneben kopiert wird, wenn man "mitte" drückt, der Text aus der Textbox daneben kopiert wird
    und wenn man "unten" drückt, der Text aus der Textbox daneben kopiert wird?

    Gut, dann mach es so:

    Spoiler anzeigen

    HTML-Quellcode

    1. <!DOCTYPE html>
    2. <html>
    3. <head>
    4. <meta http-equiv="content-type" content="text/html; charset=windows-1252"/>
    5. <title></title>
    6. <meta name="generator" content="LibreOffice 6.1.4.2 (Windows)"/>
    7. <meta name="created" content="00:00:00"/>
    8. <meta name="changed" content="2019-02-09T21:10:29.539000000"/>
    9. <link href="style.css" rel="stylesheet" />
    10. <style type="text/css">
    11. @page { margin: 2cm }
    12. p.normal { margin-bottom: 0cm; color: #000000; font-family: "Times New Roman"; font-size: 10pt; font-weight: normal }
    13. a:link { color: #0000ff }
    14. a:visited { color: #800080 }
    15. </style>
    16. </head>
    17. <body lang="de-DE" vlink="#800080" dir="ltr"><p class="normal" style="margin-bottom: 0.5cm">
    18. <font color="#f10d0c"><span style="text-decoration: none"><font face="Comic Sans MS"><font size="4" style="font-size: 14pt">#
    19. </font></font></span></font><font color="#f10d0c"><span style="text-decoration: none"><font face="Comic Sans MS"><font size="4" style="font-size: 14pt">Test
    20. Blanko Tabelle</font></font></span></font></p>
    21. <p class="normal" style="margin-bottom: 0.5cm"><br/>
    22. <br/>
    23. </p>
    24. <table width="888" cellpadding="4" cellspacing="1" style="page-break-inside: avoid">
    25. <col width="281"/>
    26. <col width="505"/>
    27. <col width="72"/>
    28. <tr valign="top">
    29. <td width="281" style="border-top: 1px double #808080; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0.1cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p class="normal" align="left">
    30. <font face="Arial"><font size="3" style="font-size: 12pt"><font color =#01DF3A>Subject:</font></font></font></p>
    31. </td>
    32. <td width="505" style="border-top: 1px double #808080; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0.1cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p>
    33. <br/>
    34. </p>
    35. </td>
    36. <td width="72" style="border: 1px double #808080; padding: 0.1cm"><p align="center">
    37. <br/>
    38. </p>
    39. </td>
    40. </tr>
    41. <tr valign="top">
    42. <td width="281" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p class="normal" align="left">
    43. <font face="Arial"><font size="3" style="font-size: 12pt"><font color =#01DF3A>Prio:</font></font></font></p>
    44. </td>
    45. <td width="505" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p>
    46. <br/>
    47. </p>
    48. </td>
    49. <td width="72" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: 1px double #808080; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm"><p align="center">
    50. <br/>
    51. </p>
    52. </td>
    53. </tr>
    54. <tr valign="top">
    55. <td width="281" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p class="normal" align="left">
    56. <font face="Arial"><font size="3" style="font-size: 12pt"><font color =#01DF3A>Anliegen:</font></font></font></p>
    57. </td>
    58. <td width="505" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p>
    59. <br/>
    60. <input type="text" value="Oben" id="myInput1">
    61. <font face="Arial, sans-serif"><font size="3" style="font-size: 12pt">-
    62. was willst du</font></font>
    63. </p>
    64. </td>
    65. <td width="72" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: 1px double #808080; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm"><p class="normal" align="center">
    66. <button onclick="myFunction('myInput1')">oben</button>
    67. <script>
    68. function myFunction(id) {
    69. // Get the text field
    70. var copyText = document.getElementById(id);
    71. // Select the text field
    72. copyText.select();
    73. copyText.setSelectionRange(0, 99999); // For mobile devices
    74. // Copy the text inside the text field
    75. navigator.clipboard.writeText(copyText.value);
    76. // Alert the copied text
    77. alert("Copied the text: " + copyText.value);
    78. }
    79. </script>
    80. </p>
    81. </td>
    82. </tr>
    83. <tr valign="top">
    84. <td width="281" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p class="normal" align="left">
    85. <font face="Arial"><font size="3" style="font-size: 12pt"><font color =#01DF3A>L&ouml;sung:</font></font></font></p>
    86. </td>
    87. <td width="505" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p>
    88. <br/>
    89. <input type="text" value="mitte" id="btncopytext">
    90. <id="btncopytext">
    91. <font face="Arial, sans-serif"><font size="3" style="font-size: 12pt">-
    92. da hast du
    93. </font></font>
    94. </p>
    95. </td>
    96. <td width="72" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: 1px double #808080; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm"><p class="normal" align="center">
    97. <button onclick="myFunction('btncopytext')">mitte</button>
    98. </p>
    99. </td>
    100. </tr>
    101. <tr valign="top">
    102. <td width="281" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p class="normal" align="left">
    103. <font face="Arial"><font size="3" style="font-size: 12pt"><font color =#01DF3A>Interner
    104. Vermerk:</font></font></font></p>
    105. </td>
    106. <td width="505" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p>
    107. <br/>
    108. <input type="text" value="Unten" id="myInput3">
    109. <font face="Arial, sans-serif"><font size="3" style="font-size: 12pt">- bekommt nix</font></font>
    110. </p>
    111. </td>
    112. <td width="72" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: 1px double #808080; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm"><p class="normal" align="center">
    113. <button onclick="myFunction('myInput3')">unten</button>
    114. </p>
    115. </td>
    116. </tr>
    117. </table>
    118. <p class="normal" style="margin-bottom: 0.5cm">&nbsp;</p>
    119. <p class="normal" style="margin-bottom: 0.5cm"><a href="Textbausteine1.htm"><button>Zur&uuml;ck</button></a></p>
    120. </body>
    121. </html>



    Du brauchst nicht für jeden Button eine Funktion.
    Hier hab ich jetzt wie auch Marcus versucht hat es zu erklären, der Funktion einen Parameter gegeben, welcher die ID der Textbox sein muss, welche kopiert wird.
    Aber fernab von der Javascript-Seite solltest du dringend dein CSS auslagern, das ist viel zu unübersichtlich was du da hast.


    Meine Website:
    www.renebischof.de

    Meine erste App (Android):
    PartyPalooza
    du hast mich richtig verstanden.

    fast so wollte ich es haben, nur noch das er das schwarze kopiert. das weiße textfeld soll nicht sein. aber so hab ich jetzt ein ansatz, wie ich es weiter machen kann.

    Und eine frage noch dazu, bei alert meldung, kann man das so mahen, das wenn mitte geklickt wird auch im text mitte steht und bei unten halt unten?

    Danke dir schonmal
    Grüße Snipy26



    Auf jeder Aktion erfolgt immer eine Re-Aktion, und selbst wenn es nur ne Fehlermeldung ist. :thumbsup:

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Snipy26“ ()

    genau. ich habe insgesamt 32 verschiedene dateien in html, die ich immer wieder benötige. und als beispiel schaut das so aus:

    zumindest soll es so werden. von der optik und aufbau her

    und die schrift hat folgenden code:

    HTML-Quellcode

    1. <font face="Arial, sans-serif"><font size="3" style="font-size: 12pt"><font color =#D8D8D8>-
    2. kd &uuml;ber inso sperre informiert<br/>
    3. - kd informiert, das
    4. sachverhalt weiter geleitet und gepr&uuml;ft wird<br/>
    5. -
    6. bearbeitungsdauer -&gt; 2-3 werktage<br/>
    7. - kd wird kontaktiert </font></font></font>


    und halt bei oden soll anliegen kopiert werden, damit ich es im daten program einfogen kann.
    bei lösung und intern das gleiche. und das daten programm hat 3 text felder mit dieser bezeichnung anliegen, löung und intern.

    und in bild 2 muss ich das halt mit strg + v einfügen. und bei texte die teilweise 20 zeilen lang sind ist das schon ne erleichterung damit. :)
    Bilder
    • beispiel 1.JPG

      112,51 kB, 751×504, 49 mal angesehen
    • beispiel 2.JPG

      39,61 kB, 710×599, 39 mal angesehen
    Grüße Snipy26



    Auf jeder Aktion erfolgt immer eine Re-Aktion, und selbst wenn es nur ne Fehlermeldung ist. :thumbsup:

    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Snipy26“ ()

    Ich habe deinen HTML-Code jetzt einfach übernommen und die Änderungen vorgenommen. Der Code ist aber wirklich schrecklich, um das nett zu sagen :D
    Du musst wirklich von Inline-CSS wegkommen und deine HTML-Struktur richtig formatieren.

    So siehts nun aus:



    Wenn man auf die Buttons drückt, wird der Text links daneben jeweils kopiert.
    Ich habe einfach ein P-Element erstellt und dem eine ID zugewiesen. Dann habe ich in der Javascript-Funktion den innerText des übergebenen Elements ausgelesen:

    Quellcode

    1. var copyText = document.getElementById(id).innerText;


    Dann wolltest du, dass in der Alert-Meldung noch der jeweilige Button-Text steht. Das kann man auf viele Wege machen, ich habe einen ganz simplen genommen.
    Die Javascript-Funktion hat nun 2 Parameter. Der erste ist das auszulesene Element, der zweite Parameter ist nun das, was noch in der Alert-Meldung stehen soll.

    Beispiel:

    Quellcode

    1. <button onclick="myFunction('idLoesung', 'Mitte')">mitte</button>




    Ganzer Code:

    Spoiler anzeigen

    HTML-Quellcode

    1. <!DOCTYPE html>
    2. <html>
    3. <head>
    4. <meta http-equiv="content-type" content="text/html; charset=windows-1252"/>
    5. <title></title>
    6. <meta name="generator" content="LibreOffice 6.1.4.2 (Windows)"/>
    7. <meta name="created" content="00:00:00"/>
    8. <meta name="changed" content="2019-02-09T21:10:29.539000000"/>
    9. <link href="style.css" rel="stylesheet" />
    10. <style type="text/css">
    11. @page { margin: 2cm }
    12. p.normal { margin-bottom: 0cm; color: #000000; font-family: "Times New Roman"; font-size: 10pt; font-weight: normal }
    13. a:link { color: #0000ff }
    14. a:visited { color: #800080 }
    15. </style>
    16. </head>
    17. <body lang="de-DE" vlink="#800080" dir="ltr"><p class="normal" style="margin-bottom: 0.5cm">
    18. <font color="#f10d0c"><span style="text-decoration: none"><font face="Comic Sans MS"><font size="4" style="font-size: 14pt">#
    19. </font></font></span></font><font color="#f10d0c"><span style="text-decoration: none"><font face="Comic Sans MS"><font size="4" style="font-size: 14pt">Test
    20. Blanko Tabelle</font></font></span></font></p>
    21. <p class="normal" style="margin-bottom: 0.5cm"><br/>
    22. <br/>
    23. </p>
    24. <table width="888" cellpadding="4" cellspacing="1" style="page-break-inside: avoid">
    25. <col width="281"/>
    26. <col width="505"/>
    27. <col width="72"/>
    28. <tr valign="top">
    29. <td width="281" style="border-top: 1px double #808080; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0.1cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p class="normal" align="left">
    30. <font face="Arial"><font size="3" style="font-size: 12pt"><font color =#01DF3A>Subject:</font></font></font></p>
    31. </td>
    32. <td width="505" style="border-top: 1px double #808080; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0.1cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p>
    33. <br/>
    34. </p>
    35. </td>
    36. <td width="72" style="border: 1px double #808080; padding: 0.1cm"><p align="center">
    37. <br/>
    38. </p>
    39. </td>
    40. </tr>
    41. <tr valign="top">
    42. <td width="281" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p class="normal" align="left">
    43. <font face="Arial"><font size="3" style="font-size: 12pt"><font color =#01DF3A>Prio:</font></font></font></p>
    44. </td>
    45. <td width="505" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p>
    46. <br/>
    47. </p>
    48. </td>
    49. <td width="72" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: 1px double #808080; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm"><p align="center">
    50. <br/>
    51. </p>
    52. </td>
    53. </tr>
    54. <tr valign="top">
    55. <td width="281" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p class="normal" align="left">
    56. <font face="Arial"><font size="3" style="font-size: 12pt"><font color =#01DF3A>Anliegen:</font></font></font></p>
    57. </td>
    58. <td width="505" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p>
    59. <p style="font-family:Arial, sans-serif font-size: 12pt" id="idAnliegen">was willst du</p>
    60. </p>
    61. </td>
    62. <td width="72" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: 1px double #808080; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm"><p class="normal" align="center">
    63. <button onclick="myFunction('idAnliegen','Oben')">oben</button>
    64. <script>
    65. function myFunction(id, sender) {
    66. // Get the text field
    67. var copyText = document.getElementById(id).innerText;
    68. // Copy the text inside the text field
    69. navigator.clipboard.writeText(copyText);
    70. // Alert the copied text
    71. alert(sender + ": " + copyText);
    72. }
    73. </script>
    74. </p>
    75. </td>
    76. </tr>
    77. <tr valign="top">
    78. <td width="281" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p class="normal" align="left">
    79. <font face="Arial"><font size="3" style="font-size: 12pt"><font color =#01DF3A>L&ouml;sung:</font></font></font></p>
    80. </td>
    81. <td width="505" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p>
    82. <p style="font-family:Arial, sans-serif font-size: 12pt" id="idLoesung">Das hast du</p>
    83. </p>
    84. </td>
    85. <td width="72" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: 1px double #808080; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm"><p class="normal" align="center">
    86. <button onclick="myFunction('idLoesung', 'Mitte')">mitte</button>
    87. </p>
    88. </td>
    89. </tr>
    90. <tr valign="top">
    91. <td width="281" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p class="normal" align="left">
    92. <font face="Arial"><font size="3" style="font-size: 12pt"><font color =#01DF3A>Interner
    93. Vermerk:</font></font></font></p>
    94. </td>
    95. <td width="505" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: none; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm"><p>
    96. <p style="font-family:Arial, sans-serif font-size: 12pt" id="idVermerk">Bekommt nix</p>
    97. </p>
    98. </td>
    99. <td width="72" style="border-top: none; border-bottom: 1px double #808080; border-left: 1px double #808080; border-right: 1px double #808080; padding-top: 0cm; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm"><p class="normal" align="center">
    100. <button onclick="myFunction('idVermerk','Unten')">unten</button>
    101. </p>
    102. </td>
    103. </tr>
    104. </table>
    105. <p class="normal" style="margin-bottom: 0.5cm">&nbsp;</p>
    106. <p class="normal" style="margin-bottom: 0.5cm"><a href="Textbausteine1.htm"><button>Zur&uuml;ck</button></a></p>
    107. </body>
    108. </html>



    Meine Website:
    www.renebischof.de

    Meine erste App (Android):
    PartyPalooza
    genau so willte ich das haben.

    kann ich den button auch wieder den effekt geben

    ccs datei:

    HTML-Quellcode

    1. H1
    2. {
    3. font-family: comic sans MS;
    4. }
    5. p
    6. {
    7. font-family: trebuchet MS;
    8. font-size: 18px;
    9. }
    10. body
    11. {
    12. background-image:url(backround1.jpg);
    13. background-position: 50% 50%;
    14. background-repeat: no-repeat;
    15. background-attachment: fixed;
    16. -webkit-background-size: cover;
    17. -moz-background-size: cover;
    18. -o-background-size: cover;
    19. background-size: cover;
    20. background-color: #000;
    21. background-repeat:no-repeat;
    22. background-position: 0px 0px;
    23. }
    24. /* Back */
    25. Button.back {
    26. font-family: comic sans MS;
    27. font-size: 18px;
    28. transition-duration: 1000ms;
    29. background: linear-gradient(to right bottom, silver,silver,white,silver,silver);
    30. border-width: 2px;
    31. border-radius: 20px 0;
    32. box-shadow: 0 0 0 rgba(0,0,0,.8);
    33. }
    34. .back:hover {
    35. font-size: 25px;
    36. transition-duration: 1000ms;
    37. cursor: pointer;
    38. border-radius: 0 20px;
    39. box-shadow: 5px 5px 1px rgba(0,0,0,.2);
    40. }
    41. /* Blue */
    42. Button.danger {
    43. border-radius: 5px;
    44. border-color: #2196F3;
    45. color: dodgerblue;
    46. }
    47. .danger:hover {
    48. border-radius: 5px;
    49. background: #2196F3;
    50. color: white;
    51. }
    52. {
    53. <h1>Outline Buttons</h1>
    54. <button class="btn back">Zurück</button>
    55. <button class="btn danger">Kopieren</button>
    56. }
    57. H2
    58. {
    59. font-family: comic sans MS;
    60. }


    beim zurück button geht es ja mit anpassen. nur bei den kopieren button kommt, wenn ich es ändere mit button class denn zu undefinied
    Grüße Snipy26



    Auf jeder Aktion erfolgt immer eine Re-Aktion, und selbst wenn es nur ne Fehlermeldung ist. :thumbsup:
    Meinst du, dass der Button sich so komisch verschiebt, wenn man mit der Maus drüberfährt?

    Wenn du das möchtest musst du den Buttons die Class "back" (In deinem CSS deklariert) zuweisen:


    HTML-Quellcode

    1. <button class="back" onclick="myFunction('idVermerk','Unten')">unten</button>


    oder

    HTML-Quellcode

    1. <button class="back" onclick="myFunction('idLoesung', 'Mitte')">mitte</button>


    Du weißt was ich meine.
    Dann sieht es so aus:



    Aber nur, weil CSS einem die Möglichkeiten gibt, sollte man nicht alles davon nutzen. Solch ein UI-Design ist nicht immer sinnig, aber das musst du entscheiden.
    Wenn es nur für dich ist und du es schön findest, dann kannst du dich ja austoben.

    Du weißt jetzt auf jeden Fall ja wie.
    Grüße


    Meine Website:
    www.renebischof.de

    Meine erste App (Android):
    PartyPalooza
    nee, das er blau ist. den button mit

    HTML-Quellcode

    1. <button class="btn danger">Kopieren</button>

    der mit verschieben ist ja nur für zurück. und der funzt schon.

    Edit: funzt alles. perfekt. ich danke euch.

    so, jetzt das ganze noch bei 32 dateien anpassen =O
    Grüße Snipy26



    Auf jeder Aktion erfolgt immer eine Re-Aktion, und selbst wenn es nur ne Fehlermeldung ist. :thumbsup:

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Snipy26“ ()

    So, mal ein Update. Eine Datei erfolgreich angepassteren funktioniert wie gewünscht. Hab den Code auch nochmal bei der Anordnung der Tabelle angepasst und gekürzt.

    es ist so wie ich es mir vorgestellt habe.

    Vielen Dank euch nochmal für die Hilfe. ☺️
    Grüße Snipy26



    Auf jeder Aktion erfolgt immer eine Re-Aktion, und selbst wenn es nur ne Fehlermeldung ist. :thumbsup: