Results 1 to 9 of 9

Thread: Automatic write text to another box.

  1. #1
    Join Date
    Nov 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Automatic write text to another box.

    Hi everyone,

    <form method="post" action="xxxx.php">
    <input type="file" size="40" name="image">
    <textarea name="desc" cols="65" rows="4" wrap="virtual"> input type=file must automaticly goes here </textarea>
    <input type="submit" name="submit" value="submit">

    take a look above forum, I want to learn, how do I it with javascript, input field must automaticly goes textarea..

    <input=file> content must goes to <textarea>goeshere</textarea>

    thx..
    Last edited by xam; 11-22-2005 at 12:57 AM.

  2. #2
    Join Date
    Nov 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Please.. I need it..

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <input type="file" size="40" name="image" onchange="this.form.elements['image'].value=this.value;"/>
    <textarea name="desc" cols="65" rows="4" wrap="virtual"></textarea>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You might like this one better:

    HTML Code:
    <form>
    <input type="file" size="40" name="image" onchange="this.form.elements['desc'].value+=this.value+'\n';"><br>
    <textarea name="desc" cols="65" rows="4" wrap="virtual"></textarea>
    </form>
    Twey's would work if ['image'].value were changed to ['desc'].value, a simple typo on his part, I'm sure. Mine adds the files to the textarea, one by one without removing the old ones, a twist on what was requested.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Nov 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    wowow.. thanks guys.. It help me alot.. but I've a problem..
    How do I change it to this:
    When I select an image, like as: image.gif, textarea must be: [image]image[/image] without extentions..

    My form:
    Select a image: flower.gif (I've selected this)
    Image name: flower (automaticly goes here without extention)
    Description: [image]flower[/image] (aumaticly goes here without extention and with [image][/image] tag.

    thx.
    Last edited by xam; 11-22-2005 at 11:33 PM.

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    this.form.elements['desc'].value+='[sc]'+this.value+'[/sc]\n'
    You don't need the \n unless you want a line break. You don't need the += unless you want it added on to previous filenames, use just = instead if you want each filename to replace the previous one in the textarea.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Nov 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1
    Code:
    this.form.elements['desc'].value+='[sc]'+this.value+'[/sc]\n'
    You don't need the \n unless you want a line break. You don't need the += unless you want it added on to previous filenames, use just = instead if you want each filename to replace the previous one in the textarea.
    Ups.. you're so fast dude, but I've edited my message sorry for that..

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    That's a little trickier, so I've written out the entire example form:

    Code:
    <form>
    Select Image: <input type="file" size="40" name="image" 
    onchange="this.form.elements['desc'].value+='[image]'+(this.form.elements['iName'].value=this.value.replace(/^.*\\|\.[^.]*$/g,''))+'[/image]\n'"><br>
    Image Name: <input type="text" name="iName" readonly><br>
    Description:<br><textarea name="desc" cols="65" rows="4" wrap="virtual"></textarea>
    </form>
    Once again, += can be just = if you don't want each successive filename prefix appended to the textarea. If you use just = you don't need the line break either (\n). Also, if you do want it appended but don't want the line break, you can ditch just the \n or replace it with character(s) and/or space(s).
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    Nov 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you very much! I've no problem now

    You're my hero.. thanks and thanks again.!

Bookmarks

Posting Permissions

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