Copy multiple Text Fields

Discussion in 'JavaScript' started by verse.thekeg, Dec 22, 2008.

  1. #1
    I have a form which I want to have the data the user submits to be copied. It is a local web-app meaning it has to work offline. Here's my attempt to get this to work.


    <script type="text/javascript">
    function copyValue(el)
    {
    document.getElementById('copy_' + el.id).innerHTML = el.value;
    }
    </script>



    First Name: <input type="text" name="First Name" style="width:160px" id="First Name" onchange="copyValue(this);">
    Last Name: <input type="text" name="Last Name" style="width:160px" id="Last Name" onchange="copyValue(this);">
    <input type="button" value="Submit"/>
    <span id="copy_First Name" style="font-weight: bold;">
    <span id="copy_Last Name" style="font-weight: bold;"></span>
     
    verse.thekeg, Dec 22, 2008 IP
  2. GreatMetro

    GreatMetro Peon

    Messages:
    117
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try closing the <span> tag....


    <script type="text/javascript">
    function copyValue(el)
    {
    document.getElementById('copy_' + el.id).innerHTML = el.value;
    }
    </script>



    First Name: <input type="text" name="First Name" style="width:160px" id="First Name" onchange="copyValue(this);">
    Last Name: <input type="text" name="Last Name" style="width:160px" id="Last Name" onchange="copyValue(this);">
    <input type="button" value="Submit"/>
    <span id="copy_First Name" style="font-weight: bold;"></span>
    <span id="copy_Last Name" style="font-weight: bold;"></span>
     
    GreatMetro, Dec 24, 2008 IP