Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sending Input to a hidden box

    Hey all. Very Greenhorn coder here. Enough to have any idea where to look and to try things.

    I am trying to get the below to go into two table


    Code:
    <p class="input">
    <label for="username"><?php echo $this->translate('Username');?> <br class="hide" /></label>
    <span class="field"><input type="text" name="username" id="username" value="<?php echo $this->username;?>" /></span>
    <span class="addtext"><?php echo $this->baseUrl;?>username</span>
    </p>
    <p class="input">
    <label for="firstname"><?php echo $this->translate('Screen Name');?> <br class="hide" /></label>
    <span class="field"><input type="text" name="firstname" id="firstname" value="<?php echo $this->firstname;?>" /></span>
    </p>
    What I essentially want to happen is hide the Screen Name section, but have whatever is typed into the Username box, be auto-copied to the Screen Name box (while its hidden).

    The other method that would work, would be to tell mySQL to copy anything from table A to table B. However, I am having more issues trying to figure out the mysql function for this, so thought I would try working on things from the front end.

    Any ideas? Or am I way off on this?

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,092
    Thanks
    23
    Thanked 594 Times in 593 Posts
    This works when you click OUT of the input box. There are other ways of doing this.
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title>Title of the document</title>
    <style type="text/css">
    #hide{
    	display:none;
    }
    </style>
    </head>
    
    <body>
    <label for="username">Full Name Please</label>
    <input type="text" name="username" id="username" onblur="show();">
    
    <div id="hide">
    <label for="firstname" style="float:left;">Your First Name</label>
    <input type="text" name="firstname" id="firstname" value="" style="float:left;">
    </div>
    
    <script type="text/javascript">
    function show(){
    	did = document.getElementById("username").value;
    	document.getElementById("firstname").value = did;
    	document.getElementById("hide").style.display = "block";
    }
    </script>
    </body>
    </html>

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,189
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts
    Pardon me for butting in, but...

    The other method that would work, would be to tell mySQL to copy anything from table A to table B.
    I have to wonder about your DB design if you have two tables involved for such simple data as user name and screen name. You might want to pose in the MySQL forum and show your DB design and ask for advice.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •