www.webdeveloper.com
Results 1 to 2 of 2

Thread: Default content (using $content) in textarea (similar to the email sys) -pls advise

  1. #1
    Join Date
    Dec 2004
    Posts
    81

    Exclamation Default content (using $content) in textarea (similar to the email sys) -pls advise

    Hi there,

    Just trying my luck to see whether I can get some help here.

    This is a very cool site http://www.kevinroth.com/rte/demo.htm (which might be helpful to some of you) where you will be able to get functions like highlight, bold, underline, very much similar to the layout that we are using in the email system.

    Well, actually I am using this sample as a reference to develop something similar to an email system. So far I can modify the codes and get what I want.

    However, I encountered some problems lately.

    If someone can be kind enough to take a look at the site and the Demo.txt file I have attached.

    Demo.txt (focus on this portion of the script)

    //We can place our predefined text in the textarea

    <?
    $content = "here's the ". chr(13) ."\"preloaded <b>content</b>\"";
    $content = RTESafe($content);
    ?>//Usage: initRTE(imagesPath, includesPath, cssFile)
    initRTE("images/", "", "");
    </script>
    <noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript>

    <script language="JavaScript" type="text/javascript">
    <!--
    //Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
    writeRichText('rte1', '<?=$content?>', 520, 200, true, false);
    //-->
    </script>



    Basically I am am trying to do is to extract something like this:


    <p>This is an example</p><p>I need to have a php <?php echo $variable?></p>


    from the database and assigning it as $content. Note that $variable is declared earlier in example.php


    Now I would like to display this text as a default statement in the textarea.


    <script language="JavaScript" type="text/javascript">
    <!--
    //Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
    //writeRichText('standard_reply', '<?php echo $content;?>', 520, 300, true, false);
    //-->
    </script>


    However, $variable cannot be displayed in the textarea.

    Which part of the script must I change such that $variable will be shown in the textarea?


    FYI, this can be done:

    [COLOR=dark red]
    writeRichText('standard_reply', '<p>This is an example</p><p>I need a php <?php echo $variable;?></p>', 520, 300, true, false); [/COLOR]

    Any advise is most appreciated.

    Thanks for reading and have a great day!
    Attached Files Attached Files
    Regards,
    Jellybean

  2. #2
    Join Date
    Dec 2004
    Posts
    81
    Hi all,

    I am thinking perhaps I have to pass $variable to richtext.js where the functions (eg. writeRichText) are stored.



    In Example.php

    Since
    $content = <p>This is an example</p><p>I need to have a php <?php echo $variable?></p>

    and
    <script language="JavaScript" type="text/javascript">
    <!--
    //Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
    <?php
    echo "writeRichText('rte1', '$content', 520, 200, true, false);";
    ?>
    //-->
    </script>


    therefore $variable has to be passed to richtext.js as well? If so, how to I pass it?



    In richtext.js

    function writeRichText(rte, html, width, height, buttons, readOnly) {
    if (isRichText) {
    if (allRTEs.length > 0) allRTEs += ";";
    allRTEs += rte;
    writeRTE(rte, html, width, height, buttons, readOnly);
    } else {
    writeDefault(rte, html, width, height, buttons, readOnly);
    }
    }


    function writeDefault(rte, html, width, height, buttons, readOnly) {
    if (!readOnly) {
    document.writeln('<textarea name="' + rte + '" id="' + rte + '" style="width: ' + width + 'px; height: ' + height + 'px;">' + html + '</textarea>');
    } else {
    document.writeln('<textarea name="' + rte + '" id="' + rte + '" style="width: ' + width + 'px; height: ' + height + 'px;" readonly>' + html + '</textarea>');
    }
    }


    Somebody please advise.

    Thanks a million!
    Regards,
    Jellybean

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles