#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    20
    Rep Power
    0

    Copy to clipboard and how exactly pass the value to the Javacript {php var}


    *Hello I was designing a form to take some value in the given fileds and return the whole as a "DRAFT"
    once the user fills the form clicks copy to clipboard the whole draft has to be copied ,if he/she clicks clear button the all fields has to be cleared ...... im trying to achieve this by using javascript ! kindly guide .. very new to php
    *

    <?php
    $accno =$_POST['accno'];
    $accanme =$_POST['accname'] ;
    $bankname = $_POST['bankname'] ;
    $branch = $_POST['branch'] ;
    $ifsc= $_POST['ifsc'] ;
    if(isset($accno) && isset($accanme) && isset($bankname) && isset($branch) && isset($ifsc))
    {
    if(!empty($accno) && !empty($accanme) && !empty($bankname) && !empty($branch) && !empty($ifsc))
    {
    $ckipboardcopy = "This mail is to intimate you that the following bank details have been updated in your merchant account <strong>".$accanme. " - " ."$accno"."</strong> from our end.The details are as follows, "."<br><br>".
    "Account No - "." $accno </br>".
    "Account Name - "." $accanme </br>".
    "Bank Name - "." $bankname </br>".
    "Branch Name - "." $branch </br>".
    "IFSC Code - "." $ifsc </br></br>". "Please do revert us for any further clarification on the above " ;
    //echo $ckipboardcopy ;
    'copyToClipboard($)' ;
    }
    else
    {
    'IsEmpty()';
    }
    }
    ?>
    <html>
    <script type="text/javascript">
    <!-- This code is used for copying the one text value to other
    function CopyIt(Which)
    {
    Which.formaccno.value=Which.accno.value;
    Which.formaccname.value=Which.accname.value;
    }
    </script>
    <script type="text/javascript" name ="IsEmpty()">
    alert("Hey ! I wont Accept Empty Fields") ;
    </script>
    <script type="text/javascript">
    function copyToClipboard ()
    var text = <?php echo ckipboardcopy ?> ;
    window.prompt ("Copy to clipboard: Ctrl+C, Enter", text);
    }
    </script>
    <form action = "venki.php" method = "POST" >
    <img src= "D:\xampp\htdocs\logo_ebs.png" DIPLAY="TRUE"> </img>
    <h1> Bank Details Updation </h1> <h2 > Merchant Form </h2>
    <link rel="stylesheet" type="text/css" href="blue.css">
    </br></br>
    <tr> This mail is to intimate you that the following bank details have been updated in your merchant account <strong>
    <input type="textbox" name ="accname"> - <input type="textbox" name="accno" value="" maxlength ="5" ></strong> from our end.The details are as follows,</tr>
    <input type ="checkbox" value=" Copy " onclick="CopyIt(this.form)" >
    </br></br></br>
    <table border="2"align ="centre">
    <tr length = "20"><td length ="10"> Account No </td> <td> <input type="textbox" name="formaccno" value="" maxlength ="5" ></td> </tr>
    <tr length = "20"><td length ="10"> Account Name </td> <td> <input type="textbox" name="formaccname" value="" size =" 20" ></td> </tr>
    <tr length = "20"><td length ="10"> Bank Name </td> <td> <input type="textbox" name="bankname" value="" size =" 20" ></td> </tr>
    <tr length = "20"><td length ="10"> Branch Name </td> <td> <input type="textbox" name="branch" value="" size =" 20" ></td> </tr>
    <tr length = "20"><td length ="10"> IFSC Code </td> <td> <input type="textbox" name="ifsc" value="" size =" 20" ></td> </tr>
    </table>
    <input type="textbox" value="<?php echo $ckipboardcopy?>" ID="txtArea">
    </br>
    Please do revert us for any further clarification on the above.
    </br></br></br></br>
    <table>
    <tr>
    <td>
    <input type ="button" onClick="copyToClipboard()" value="Copy to clipboard"/></td>
    <td>
    <input type = "submit" name="clear"/></td>
    </tr>
    </table>
    </form>
    </html>
  2. #2
  3. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,184
    Rep Power
    492
    srinidelite

    Welcome to the forum; this sounds more like a Javascript query than a PHP one; also, you've not said anything about what happens now, does it work, does it fail, do you get an error and so on. We'd also appreciate it it you can tell us what debugging, if any, you have tried so far to try to figure out what is going wrong.

    There's a really useful post, here, which has some debugging tips and tricks along with some useful things you'll need to read if you're wanting some help from the community here.

    If you can please tell us more info on the problem and what you've already tried to do to fix it, we'll be in a better position to help you.
    Regards
    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    20
    Rep Power
    0
    Hi badger_fruit ,

    It works fine !
    if i echo out the varibale $ckipboardcopy ,it will display the hole message in a correct format .

    but my question is that how can i copy the whole text ? using JS
    even with the format !! ...

    and finally want to notify the user that !!
    "Hey ! it's Copied" kind of a message !

    Got it?

IMN logo majestic logo threadwatch logo seochat tools logo