Connecting Tech Pros Worldwide Forums | Help | Site Map

textarea predefined text

Newbie
 
Join Date: Jun 2009
Posts: 4
#1: Jun 19 '09
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>

Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,748
#2: Jun 19 '09

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.
Newbie
 
Join Date: Jun 2009
Posts: 4
#3: Jun 19 '09

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!
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,748
#4: Jun 19 '09

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. ?>
Newbie
 
Join Date: Jun 2009
Posts: 4
#5: Jun 19 '09

re: textarea predefined text


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

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.
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,748
#7: Jun 19 '09

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