What's new

Closed Help sa copy to clipboard code

Status
Not open for further replies.

zentrix06

Honorary Poster
Joined
Jan 10, 2016
Posts
612
Reaction
110
Points
224
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.

Similar threads

Back
Top