Welcome Guest [Log In] [Register]

Welcome to Big Boards. Big Boards at one time offered the Zathyus network our long famous Resource Archives, our extensive search indexes, and our info-packed resource forums. Eventually, these were made redundant by upgrades to the documentations and expanded search features added to the ZetaBoards software, and this forum then lost relevancy and subsequently became inactive.

Our team then embarked on a new project called Planet Nexus, where a bold new experiment in forum promotion is taking place. We call it nexworking. NexusTree offers social networking pages for forums in a fully automated format. Your NexusTree page is created instantly when your join the nexus. Find out more by visiting Planet Nexus, and become part of the nexworking revolution.

Posted Image Posted Image
If you're already a member please log in to your account for additional access:

Username:   Password:
Closed Topic
Adding content to a textarea
Topic Started: Aug 10 2009, 09:16 PM (398 Views)
C0smic1
BB Alpha
[ * ]
What browser(s) are you using? Chrome
Your Issue/Question: What code would you use to add content to the end of a textarea? I would like to place a button above a text area which will add content at the end of the text field in a similar way to invisionfree places BBcode into the textarea, so how could I do this? Thanks in advance!

P.S. Also, you wouldn't mind explaining you you make things like the site map of this site slide across the screen the the indexes box expand when opening them, could you? I'm just interested, I don't want to plagiarize you or anything =P.
Posted Image
Offline
Profile
Goto Top
 
Cory
Member Avatar


Try this:
Quote:
 
<script type="text/javascript">
function doIt() {
$("#c_post-text").val($("#c_post-text").val() + "Text to Append");
return false;
}
$('#c_bbcode').append("<button style='margin-top:3px;margin-left:3px;' type='button' onclick='return doIt();'>Button Text</button>");
</script>
Change the IDs accordingly if you're not using ZB.

We're using jQuery to accomplish those effects.
Offline
Profile
Goto Top
 
C0smic1
BB Alpha
[ * ]
It doesn't seem the work. I don't need any sort of method to place the button where it belongs, I just need the text to be placed at the end of the textarea upon being pressed. I tried changing the ideas but the button didn't do anything upon being pressed.

Here is the sort of situation I have:
Quote:
 
<table><tr><td>BUTTON TO ADD TEXT GOES HERE<td></tr>
<td> Field Name:</td>
<td><textarea id="textarea" cols="20">Default text</textarea></td>
</tr></table>
As said before, just as long as it adds text it'll do. I'm not even using ZB, so a code to place the button somewhere wouldn't help anyway. Also, thanks for telling me about the jQuery, I'll make sure to look into that.
Posted Image
Offline
Profile
Goto Top
 
Cory
Member Avatar


Quote:
 
<script type="text/javascript">
function doIt() {
$("#c_post-text").val($("#c_post-text").val() + "Text to Append");
return false;
}
</script>

<table><tr><td><button type='button' onclick='return doIt();'>Button Text</button><td></tr>
<td> Field Name:</td>
<td><textarea id="c_post-text" cols="20">Default text</textarea></td>
</tr></table>
Try that instead.
Offline
Profile
Goto Top
 
C0smic1
BB Alpha
[ * ]
Still doesn't work for some reason. To see a test of it go to my (link removed) to view the results. For reference, other javascripts are working fine and I'm using google chrome.
Edited by C0smic1, Aug 12 2009, 07:36 PM.
Posted Image
Offline
Profile
Goto Top
 
Cory
Member Avatar


Wrap the head tags around the JavaScript.
Offline
Profile
Goto Top
 
C0smic1
BB Alpha
[ * ]
I put the head tags around the script tags but still no luck.
Posted Image
Offline
Profile
Goto Top
 
Cory
Member Avatar


Silly me, I forgot you had to enable jQuery.

Add the following script between the head tags as well.
Code:
 
<script type="text/javascript" src="http://z5.ifrm.com/static/jq.js"></script>
Offline
Profile
Goto Top
 
C0smic1
BB Alpha
[ * ]
Thanks, it works perfectly now. I'm now deleting that text page. Thanks a lot, you can archive this thread whenever you like.
Posted Image
Offline
Profile
Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Global Support Archive · Next Topic »
Closed Topic