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 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2002
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Updating textbox with links assitance

    Is there a way to do the following in Javascript?

    I have a list of words that I whish to convert into links to add to a textbox

    $list="Blue; Clear Sky; Erode; Erosion; Pole; Sea; Shadow; Sky; Weather; Wood";

    What I need is to get each one as a link
    Code:
    <a href="#" onClick="addToTextbox()">Blue</a>
    <a href="#" onClick="addToTextbox()">Clear Sky</a>
    <a href="#" onClick="addToTextbox()">Erode</a>
    But everytime the user clicks a new word it will be added to the ones already in the textbox, with a " AND " prefix

    Thnaks in advance for any help

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Do You mean something like this?

    PHP Code:
    <script type="text/javascript">


    firstRun=0
    function addToTextbox(str){

    if(
    firstRun==0){
    document.forms["formName"]["t1"].value=str
    }
    else{
    document.forms["formName"]["t1"].value+=" AND "+str
    }
    firstRun=1
    }


    </script>


    <form name="formName">
    <input type="text" name="t1" size=80>
    </form>


    <a href="#" onClick="addToTextbox('Blue')">Blue</a>
    <a href="#" onClick="addToTextbox('Clear Sky')">Clear Sky</a>
    <a href="#" onClick="addToTextbox('Erode')">Erode</a> 
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.


  •  

    Posting Permissions

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