Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Appending to a text field

Appending to a text field
Thread Tools
macgyvr64
Grizzled Veteran
Join Date: Jun 2001
Status: Offline
Reply With Quote
Nov 8, 2003, 02:55 AM
 
Is there any simple way (possibly using Javascript) to append some text to a field in a form, like the buttons below this one *should* do? I was looking at the html/js source for a php-powered forum where the buttons work, but stuff is all over the place. Something nice and plain will do the trick :-P

I'm working on a project to admin a website based on simple text files, and I'd like users to be able to click on buttons like "New Line" and have a br tag be appended to the field. Stuff like that.
     
mzllr
Registered User
Join Date: Jul 2003
Location: San Jose
Status: Offline
Reply With Quote
Nov 8, 2003, 04:27 AM
 
something like this...

[php]
<html>

<head>

<script language="JavaScript" type="text/javascript">
function newLine(t)
{
document.myForm.myText.value = t + "<.br>";
}
</script>

</head>

<body>

<form action="someAction" method="post" name="myForm">
<textarea cols="50" rows="10" name="myText">Write your text here</textarea>
<input name="break" onClick="newLine(document.myForm.myText.value);" value="New Line" type="button">
</form>

</body>

</html>
[/php]

see it here
     
macgyvr64  (op)
Grizzled Veteran
Join Date: Jun 2001
Status: Offline
Reply With Quote
Nov 8, 2003, 11:20 AM
 
That is *exactly* what I wanted! Thanks a bunch!
     
redJag
Senior User
Join Date: Dec 2002
Status: Offline
Reply With Quote
Nov 9, 2003, 03:47 PM
 
Keep in mind that the buttons when posting should let you put the cursor where you want the text to go..maybe.
Travis Sanderson
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 04:20 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,