Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Oct 2004
    Posts
    104
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Changing value of a text box

    Hi there,
    Just like this forum got, you have a button saying 'B'. when you click it, it adds the Bold tag, making all text after it bold, untill the end tag. What I want to do is simply, make a short javascript (function), which will have 2 vars, so like:
    Code:
    function bold(form, textbox)
    I have no idea if that will work, as this is my very first thing in javascript. When the button 'B' (Form input type="Button") is pushed, I want to add [B] onto the end of document.form.textbox.value.

    How would I do this?
    Thanks
    -NeoPuma

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try searching the forum using the keywords: insert bbCode

    This question has been asked numerous times and there are quite a few examples floating about....

    .....Willy

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    I think the easiest way is by changing CSS "on-the-fly"

    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <
    html>
    <
    head>
    <
    title>Untitled Document</title>
    <
    meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <
    meta http-equiv="Content-Style-Type" content="text/css">
    <
    meta http-equiv="Content-Script-Type" content="text/javascript">
    <
    script language="JavaScript" type="text/JavaScript">
    function 
    boldT(f,t){
    f.elements[t].style.fontWeight='bold';
    }
    </script>
    </head>
    <body>
    <form>
    <input name="textbox" type="text">
      <input type="button" onclick="boldT(this.form,'textbox')" value="Bold">
    </form>
    </body>
    </html> 
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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