SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Text Formatting

  1. #1
    SitePoint Enthusiast rramroop's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Text Formatting

    Hi,
    I'm trying to format the content of an article with javascript. The script works like this. The user clicks on the "Bold button" and he gets a prompt asking him to enter the text which is going to be bold. Then the text is automatically enclosed in [ B]Text here[/ B] in the textarea. The script works fine. But what I want to do is to display the [ B]content[/ B] tag in another textarea of another page.

    What I want to call the formatting buttons in a popup window and the the tags are inserted in the mainpage textarea wich is articles.php

    Here is the code that I'm using:

    -----------------Formatting.php--------------------------
    ?php

    # Javascript for Formatting and Form Check
    echo "<script language=\"Javascript\">";
    echo " function x () {";
    echo " return;";
    echo " }";
    echo " function DoPrompt(action) {";
    echo " var revisedMessage;";
    echo " var currentMessage = document.gbookForm.more.value;";
    echo " if (action == \"bold\") {";
    echo " var thisBold = prompt(\"Enter the text that you want to make bold.\", \"\");";
    echo " var boldBBCode = \"[ B]\"+thisBold+\"[/ B]\";";
    echo " revisedMessage = currentMessage+boldBBCode;";
    echo " document.gbookForm.more.value=revisedMessage;";
    echo " document.gbookForm.more.focus();";
    echo " return;";
    echo " }";
    echo " }";
    echo "</SCRIPT>";

    echo "<TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0'>";
    echo "<FORM NAME='gbookForm' ACTION='index.php' TARGET=articles.php METHOD='POST'>";
    echo "<TR><TD>";
    echo "<A href='javascript: x()' onClick='DoPrompt(\"bold\");'><IMG src='images/bbbold.gif' hspace='1' border='0' alt='Bold Text'></A>";
    echo "</TD></TR>";
    echo "<TD valign='top'><TEXTAREA COLS='50' ROWS='8' NAME='more' class='inputbox' wrap='VIRTUAL'>$more</TEXTAREA></TD></TR>";
    echo "</TR></FORM></TABLE>";

    ?>
    -------------------------End of Script----------------------------

    I want to remove the ><TEXTAREA COLS='50' ROWS='8' NAME='more' class='inputbox' wrap='VIRTUAL'>$more</TEXTAREA> and place it in articles.php

    Can anybody help on this one.

    Cheers
    Ravi

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Before I give you a more direct answer, do you think something like this would work as well?
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  3. #3
    SitePoint Enthusiast rramroop's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your script is actually very good. Can I have it to play around with the code and see how it works?

    What I'm trying to do is when the user clicks on the IMG button a window pops up where he can upload a picture to the server rather than upload it by ftp and write the url. After uploading the picture without errors, he can then click on the ADD PICTURE button where the textarea is automatically updated with the [ IMG]filename.jpg[ /IMG] tags and the pop up window closes.

  4. #4
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, you may use it. That's what I made it for
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  5. #5
    SitePoint Enthusiast rramroop's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok Thanks. :-)
    Can you be of any help to what I'm trying to do? Or know some similar case tutorials


Bookmarks

Posting Permissions

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