PDA

View Full Version : Automatic write text to another box.



xam
11-22-2005, 12:54 AM
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..

xam
11-22-2005, 02:45 PM
Please.. I need it..

Twey
11-22-2005, 04:14 PM
<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>

jscheuer1
11-22-2005, 10:47 PM
You might like this one better:


<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.

xam
11-22-2005, 11:20 PM
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 without extentions..

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

thx.

jscheuer1
11-22-2005, 11:37 PM
this.form.elements['desc'].value+=''+this.value+'\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.

xam
11-23-2005, 12:17 AM
this.form.elements['desc'].value+=''+this.value+'\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.. :o

jscheuer1
11-23-2005, 05:12 AM
That's a little trickier, so I've written out the entire example form:


<form>
Select Image: <input type="file" size="40" name="image"
onchange="this.form.elements['desc'].value+=''+(this.form.elements['iName'].value=this.value.replace(/^.*\\|\.[^.]*$/g,''))+'\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).

xam
11-23-2005, 02:21 PM
Thank you very much! I've no problem now :)

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