🔒 Closed Help sa copy to clipboard code

Status
Not open for further replies.

zentrix06

Honorary Poster
need help lang sa mga web developers.

pano po magcode ng copy to clipboard na ang magiging result e ganito

label [textbox] copy to clipboard button
label [textbox] copy to clipboard button
label [textbox] copy to clipboard button
label [textbox] copy to clipboard button
label [textbox] copy to clipboard button
 
HTML:
<!DOCTYPE html>
<html>
<head>
    <title> Copy Mo Mukha Mo </title>
</head>
<body>
    <div>
        <label for="text_1"> Label 1 </label>
        <input type="text" name="text_1" id="text_1"> 
        <button onclick="copyMoTo(1)"> Copy to clipboard </button> 
    </div>
    <div>
        <label for="text_2"> Label 2 </label>
        <input type="text" name="text_2" id="text_2"> 
        <button onclick="copyMoTo(2)"> Copy to clipboard </button> 
    </div>
    <div>
        <label for="text_3"> Label 3 </label>
        <input type="text" name="text_3" id="text_3"> 
        <button onclick="copyMoTo(3)"> Copy to clipboard </button> 
    </div>
    <div>
        <label for="text_4"> Label 4 </label>
        <input type="text" name="text_4" id="text_4"> 
        <button onclick="copyMoTo(4)"> Copy to clipboard </button> 
    </div>
    <div>
        <label for="text_5"> Label 5 </label>
        <input type="text" name="text_5" id="text_5"> 
        <button onclick="copyMoTo(5)"> Copy to clipboard </button> 
    </div>
</body>
<script type="text/javascript">
    function copyMoTo(textbox_position) {
        var text_box = document.getElementById("text_" + textbox_position);

        text_box.select();

        document.execCommand("Copy");
    }
</script>
</html>
 
HTML:
<!DOCTYPE html>
<html>
<head>
    <title> Copy Mo Mukha Mo </title>
</head>
<body>
    <div>
        <label for="text_1"> Label 1 </label>
        <input type="text" name="text_1" id="text_1">
        <button onclick="copyMoTo(1)"> Copy to clipboard </button>
    </div>
    <div>
        <label for="text_2"> Label 2 </label>
        <input type="text" name="text_2" id="text_2">
        <button onclick="copyMoTo(2)"> Copy to clipboard </button>
    </div>
    <div>
        <label for="text_3"> Label 3 </label>
        <input type="text" name="text_3" id="text_3">
        <button onclick="copyMoTo(3)"> Copy to clipboard </button>
    </div>
    <div>
        <label for="text_4"> Label 4 </label>
        <input type="text" name="text_4" id="text_4">
        <button onclick="copyMoTo(4)"> Copy to clipboard </button>
    </div>
    <div>
        <label for="text_5"> Label 5 </label>
        <input type="text" name="text_5" id="text_5">
        <button onclick="copyMoTo(5)"> Copy to clipboard </button>
    </div>
</body>
<script type="text/javascript">
    function copyMoTo(textbox_position) {
        var text_box = document.getElementById("text_" + textbox_position);

        text_box.select();

        document.execCommand("Copy");
    }
</script>
</html>


swak.. salamat master!
 
Status
Not open for further replies.

About this Thread

  • 4
    Replies
  • 799
    Views
  • 2
    Participants
Last reply from:
Mrkmrk

Trending Topics

Online now

Members online
1,099
Guests online
1,232
Total visitors
2,331

Forum statistics

Threads
2,273,711
Posts
28,951,031
Members
1,234,928
Latest member
korn bill
Back
Top