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 8 of 8
  1. #1
    New Coder
    Join Date
    Feb 2004
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    What is the best way to forward Textarea data?

    What is the best/simplest way to forward textarea data so that if on page1.html there is a textarea with new data entered in the following format:
    ======
    Pencil
    Pen
    ======

    when submit is clicked, the data should be sent to a textarea on page2.html

    I know how to do this with input areas where data has to be in one line, but with the textarea i want the data to be on seperate links, one under the other - not everything forced into one line.

    What is the best/simplest way to implement this?

    Thanks

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    Kansas City, Kansas
    Posts
    1,518
    Thanks
    0
    Thanked 2 Times in 2 Posts
    How did you do it with input fields? Sounds to me like this is more of a server-side questions since javascript can't read/write to a file without IE activeX, which is what you would need to do if you were to accomplish this with javascript.

  • #3
    New Coder
    Join Date
    Feb 2004
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is what i used:

    page1.html
    PHP Code:
    <html
    <
    body
    <
    form method="GET" action="page2.html"
    <
    input type=text name=myvar>
    <
    input type=submit value="submit">
    </
    form
    </
    body
    </
    html
    page2.html
    PHP Code:
    <html
    <
    body
    <
    script>
    startat window.location.search.length
    myvar
    =window.location.search.substring(7,startat);
    </script> 

    <form name="whatever"> 
    <input type="text" name="newvar" value=myvar> 
    </form> 
    </body> 

    <script> 
    document.forms["whatever"].newvar.value = myvar; 
    </script> 
    </html> 
    </body>
    </html> 
    Another question, is there a way to force a textarea box to interpret a "\n" as being a breakline as opposed to treating it as normal text?

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Location
    Kansas City, Kansas
    Posts
    1,518
    Thanks
    0
    Thanked 2 Times in 2 Posts
    This question does in fact belong in the php section of these forums. Hopefully a mod will see this and be nice enough to move it for you.

  • #5
    New Coder
    Join Date
    Feb 2004
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No, i want somehow to do this with javascript - i don't want php.

    Anyone know whether there is a way to force a textarea box to interpret a "\n" as being a breakline as opposed to treating it as normal text?

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,050
    Thanks
    0
    Thanked 251 Times in 247 Posts
    You need to unescape the value parsed from URL to get its actual value. If you use textareas in your pages and use your existing code, the text will display newlines as newlines in the textarea.

    <script>
    document.forms["whatever"].newvar.value = unescape(myvar);
    </script>

    There is a better script that can parse multiple URL querystrings. Your existing code will only work if there is only one 5-letter parameter. In that script, you don't need to unescape the value as the script already does it for you.

  • #7
    New Coder
    Join Date
    Feb 2004
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That works great
    One other thing, the method i'm using, if i use two words and they have a space in between - once it gets sent to the textarea in the next page, the words end up having a "+" in between them because the address bar has a "+" in it. Is there anyway to replace "+" with a space instead?

    Thanks

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,050
    Thanks
    0
    Thanked 251 Times in 247 Posts
    I think the script I linked handles that properly. Are you using that script?


  •  

    Posting Permissions

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