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
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool inputfield content to be displayed instantly at several places on page

    Hi, it's my first post here in this forum.

    I hope someone can help me:

    I want to have a normal text input field and whatever someone types should be instantly displayed at several places on the page.

    So if someone types "hallo" in the input field then I want the following links to be created and fully displayed:

    http :// search.yahoo.com/search?p=hallo
    http :// w w w .google.com/search?q=hallo

    Is that possible with JavaScript?

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    <script type="text/javascript">
    function writeLink()
    {
    	var elem = document.getElementById('thelinks');
    	while (elem.hasChildNodes())
    		elem.removeChild(elem.firstChild);
    	var link1 = document.createElement('a');
    	var link1text = document.createTextNode('http://search.yahoo.com/search?p='+document.forms[0].query.value);
    	var thebr = document.createElement('br');
    	var link2 = document.createElement('a');
    	var link2text = document.createTextNode('http://www.google.com/search?q='+document.forms[0].query.value);
    	link1.setAttribute('href','http://search.yahoo.com/search?p='+document.forms[0].query.value);
    	link1.appendChild(link1text);
    	link2.setAttribute('href','http://www.google.com/search?q='+document.forms[0].query.value);
    	link2.appendChild(link2text);
    	elem.appendChild(link1);
    	elem.appendChild(thebr);
    	elem.appendChild(link2);
    }
    </script>
    </head>
    
    <body>
    <form action="#" method="post">
    <input type="text" name="query" onkeyup="writeLink()">
    <div id="thelinks"></div>
    </form>
    </body>
    </html>
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    W-W-Wonderful....

    I am sitting here in awe with a bag of popcorn and analyzing this swift solution....



    Thank you, _Aerospace_Eng_!


  •  

    Posting Permissions

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