...

View Full Version : inputfield content to be displayed instantly at several places on page



knnknn
08-28-2006, 02:07 AM
Hi, it's my first post here in this forum. :D

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? :cool:

_Aerospace_Eng_
08-28-2006, 06:48 AM
<!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>

knnknn
08-29-2006, 10:45 AM
W-W-Wonderful....

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

:thumbsup:

Thank you, _Aerospace_Eng_!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum