Results 1 to 3 of 3

Thread: onclick form

  1. #1
    Join Date
    Feb 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default onclick form

    Hi
    I am writing my own mini cms mostly in php
    I writtern my own news with bbcode type links
    I want to ba able to add text to my form when bbcode images are clicked
    I.E click B and [b][\b] is added to form (just like this text box i am posting in now)
    now i found a snippet of code that does this but my problem is using it for all my images B I U img etc etc i guess i need to add id some how
    HTML Code:
    <html>
    
    <head>
    
    <title></title>
    
    <script type="text/javascript" language="javascript"><!--
    
    function ChgText()
    {
       var MyElement = document.getElementById("MyTextBox");
       MyElement.value = "[b][\b]!";
    
       return true;
    }
    
    //--></script>
    
    
    </head>
    
    <body>
    
    <br><br>
    <center>
    <img src="my_image.gif" alt="Click Me!" onClick="ChgText()" />
    
    <br><br><br>
    
    <input type="text" size="35" id="MyTextBox" />
    
    </center>
    
    </body>
    </html>
    Thanks

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Try this:
    Code:
    <html>
    
    <head>
    
    <title></title>
    
    <script type="text/javascript" language="javascript"><!--
    
    function ChgText(s)
    {
       var MyElement = document.getElementById("MyTextBox");
       MyElement.value = "["+s+"][\"+s+"]";
    
       return true;
    }
    
    //--></script>
    
    
    </head>
    
    <body>
    
    <br><br>
    <center>
    <img src="my_image.gif" alt="Click Me!" onClick="ChgText('b')" /><!-- This makes the Bold click --!>
    
    <img src="my_image.gif" alt="Click Me!" onClick="ChgText('i')" /><!-- This makes the Italics click --!>
    
    <img src="my_image.gif" alt="Click Me!" onClick="ChgText('u')" /><!-- This makes the Underline click --!>
    <br><br><br>
    
    <input type="text" size="35" id="MyTextBox" />
    
    </center>
    
    </body>
    </html>
    Edit: Read the comments in the HTML!
    Jeremy | jfein.net

  3. #3
    Join Date
    Feb 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks Nile for quick reply i can see how that would work
    first i just edited my code no luck
    so i pasted your code into notepad2 & dreamweaver the highlighting is wrong so i guess tag missing somewhere but i can t seem to see where

    obviously i removed your comments
    Last edited by EKsparky; 02-08-2008 at 02:17 PM.

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
  •