Connecting Tech Pros Worldwide Help | Site Map

textarea predefined text

  #1  
Old June 19th, 2009, 12:09 AM
Newbie
 
Join Date: Jun 2009
Posts: 4
Hey how are you guys?
Well I have a little question.
How can I add predefined text to this textarea? :S .
Thanks in advanced :D.

Expand|Select|Wrap|Line Numbers
  1. <tr>
  2.         <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
  3.           <tr class="infoBoxContents">
  4.             <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  5.               <tr>
  6.                 <td><?php echo tep_draw_textarea_field('comments', 'soft', '60', '5', $comments); ?></td>
  7.               </tr>
  8.             </table></td>
  9.           </tr>
  10.         </table></td>
  11.       </tr>

Last edited by Atli; June 19th, 2009 at 12:16 AM. Reason: Changed [quote] tags to [code] tags.
  #2  
Old June 19th, 2009, 12:20 AM
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,701
Provided Answers: 4

re: textarea predefined text


Hi.

Is that function meant to create your textarea?
If so, you would have to edit that function.

You could simply add a parameter for the predefined text, and have it added when the function prints the textarea.
  #3  
Old June 19th, 2009, 12:24 AM
Newbie
 
Join Date: Jun 2009
Posts: 4

re: textarea predefined text


Hrmm, okay I see.
You think the function could be <tr class="infoBoxContents"> by any chance?
And thanks for replying so fast!
  #4  
Old June 19th, 2009, 12:42 AM
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,701
Provided Answers: 4

re: textarea predefined text


Nope, that would be the top of a table row :)

The function I suspect is creating your textarea is tep_draw_textarea_field.
Do you have that anywhere?

In any case, a simpler, albeit less elegant, way to do this would be to just put the textarea into a PHP variable before echoing it and injecting your text.

Somewhat like:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // The text that should be added
  3. $predefinedText = "Hello, this is some text to inject into the textarea.\n\n";
  4.  
  5. $originalArea = tep_draw_textarea_field('comments', 'soft', '60', '5', $comments);
  6. echo preg_replace('/(<textarea[^>]*>)/i', '$1'.$predefinedText, $originalArea);
  7. ?>
  #5  
Old June 19th, 2009, 01:08 AM
Newbie
 
Join Date: Jun 2009
Posts: 4

re: textarea predefined text


Awsome!
I will give this a try right away, thank you very much.
I'll reply with results.
  #6  
Old June 19th, 2009, 01:24 AM
Newbie
 
Join Date: Jun 2009
Posts: 4

re: textarea predefined text


Yay.
Worked very well!!!!
You rock Atli :D.
Thank you very much, I hope to stay in this community, and later on help others.
  #7  
Old June 19th, 2009, 02:01 AM
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,701
Provided Answers: 4

re: textarea predefined text


I'm glad it worked!
Hope I'll be seeing you around :)
Reply

Tags
mysql, php, predefined, tep_draw_textarea_field, text, textarea


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare text in a textarea deepthiu answers 3 July 11th, 2007 10:13 AM
Capturing Keystrokes that are not permitted within a TextArea @sh answers 14 December 22nd, 2005 10:15 PM
insert text in textarea on right click in java script Max answers 6 July 20th, 2005 12:30 PM
Allow user to fill predefined space Roderick Thomas answers 1 July 20th, 2005 12:16 PM