Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-28-2006, 02:07 AM   PM User | #1
knnknn
New to the CF scene

 
Join Date: Aug 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
knnknn is an unknown quantity at this point
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?
knnknn is offline   Reply With Quote
Old 08-28-2006, 06:48 AM   PM User | #2
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
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!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 08-29-2006, 10:45 AM   PM User | #3
knnknn
New to the CF scene

 
Join Date: Aug 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
knnknn is an unknown quantity at this point
W-W-Wonderful....

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



Thank you, _Aerospace_Eng_!
knnknn is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:57 PM.


Advertisement
Log in to turn off these ads.