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 4 of 4
  1. #1
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post

    Question Help with function

    Im not sure how to do this so i need your guyses help. Im trying to make a function that copys a text box value to a other text box value but only copy a specific part of the text boxs text. Sorry if i didint write the question well, i can try to post some code if needed.

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,032
    Thanks
    36
    Thanked 495 Times in 489 Posts

    Exclamation

    Quote Originally Posted by sherlockturtle View Post
    ...oxs text. Sorry if i didint write the question well, i can try to post some code if needed.
    That would be nice!

  • #3
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,775
    Thanks
    55
    Thanked 519 Times in 516 Posts
    What you really have to decide is *which* specific part of the text you want to put into the other text box. The code below looks for a dash - in a text and splits it in two there, putting the two halves into two boxes.

    Code:
    <!DOCTYPE html>
    <html>
      <head>
      <title>boxsplit</title>
            <meta charset="UTF-8">
    	<script type="text/javascript">
    	function splitBoxes() {
    	str=document.getElementById('tb1').value;
    	document.getElementById('tb2').value=str.split("-")[0];
    	document.getElementById('tb3').value=str.split("-")[1];
    	}
    	</script>
    </head>
    
    <body>
    <input id="tb1" type="textbox"></input>
    <input type="button" value="Split!" onclick="splitBoxes()">
    <input id="tb2" type="textbox"></input>
    <input id="tb3" type="textbox"></input>
    </body>
    </html>
    but without further details about what you want to do, it's hard to see how to be of much more help...

  • #4
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    thanks xelawho


  •  

    Posting Permissions

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