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 7 of 7
  1. #1
    New to the CF scene
    Join Date
    May 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    paste to multiple fields

    Hi,

    I was wondering if javascript can do this or if theres other code (PHP) that can do this. What I wanted to do is paste a string lets say "01 02 03" into 3 fields and it would populate the first field with 01 and the second one with 02 and so on. I didn't know if this could be done or not. any advice would be much appreciated. Thanks in advance

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Sure.
    How you do that depends on where the string originally comes from and where you're putting it.
    If you've already got it on the server before the user ever sees anything, use PHP and just set the form field values as desired.
    If you're getting it on the client, use javascript, and split on the space, then use formname.elementname.value to set it.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Look at the Paste Splitter in my sig.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #4
    New to the CF scene
    Join Date
    May 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    so with your code...would I be able to split it with spaces??

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Quote Originally Posted by apdraogn View Post
    so with your code...would I be able to split it with spaces??
    Yes. Please remove the window.status statements in the code. I only used them for debugging purposes and forgot to remove it.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #6
    New to the CF scene
    Join Date
    May 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    how can I just set it so that it only separates on the spaces? Also lets say I have 5 values "1 2 3 4 5" what if one of those values are spaces will it know to put the values in the correct fields? or does the values have to be in a certain format to be put in the correct fields? I am guessing that depending on the max length it will fill the fields up to that length even though values might not be that length???

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You can have the following:

    12345
    1 2 3 4 5 (should only be one space in between)
    1-2-3-4-5 (can use any delimiter such as / * . or any non-numeric character)
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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