TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-22-2011, 08:12 PM   #1 (permalink)
The Contributor
 
Tim Dobson's Avatar
 
Join Date: Feb 2010
Posts: 69
Thanks: 16
Tim Dobson is on a distinguished road
Default Add to text field when clicked?

1 button and 1 text area

PHP Code:
<textarea name="addpaste" cols="100" rows="25" id="addpaste"></textarea>
<
br />
<
input type="button" value="Bold" name="addbld" /> 
Now what i need to do is when the the button is pressed i need [bld] to be inserted in to the textarea. Any suggestions? thanks.
Tim Dobson is offline  
Reply With Quote
Old 03-23-2011, 12:06 AM   #2 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

It seems that you want that to be accomplished in the client side, using javascript. I know how to insert text, but I am not sure how to insert it where the cursor is at.

If you just want to insert it. here is some sample code :
javascript Code:
//add an id to the textarea with same as name also to button
document.getElementById('addbld').onClick(function(){
  var txtArea = document.getElementById('addpaste');
  txtArea.value = textArea.value + '[bld]';
});

I am not an expert on javascript though. It has been a while.
tony is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkboxes working with text field Tim Dobson Absolute Beginners 1 10-02-2010 02:49 AM
create .txt with text in the field? Tim Dobson General 6 02-28-2010 04:00 AM
Input-field with captured text falsely empties on click sidisinsane Javascript, AJAX, E4X 5 12-05-2008 12:12 AM
seeding an input text field with a string joby1 XHTML, HTML, CSS 2 01-03-2008 05:34 PM
PDF Creation - Help! Sam Granger General 7 10-31-2007 11:32 AM


All times are GMT. The time now is 08:35 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design