...

View Full Version : Variable in HTML Link



garethr
08-19-2005, 12:05 PM
Hi,
I am trying to have a link from an image which goes to a page:
SearchView&Query= "+ fullname +"
taking the value fullname from a text box.

I am unsure how to do this exactly, as when you use document.write the link gets written when the page loads and can't be changed.
I don't want to use window.open function as it creates a new session which I want to avoid.
Any help would be greatly appreciated

<HTML>
<Title>JS Search</TITLE>

<head>
<script type="text/javascript">
var fullname = "";

function getVar()
{
fullname = document.tim.name.value;
}
</script>

</head>
<body onLoad="getVar();">

<form name="tim">
<input onchange="getVar()" title="Search the staff directory" style ="VERTICAL-ALIGN: 3px" display="inline" maxlength=255 class="ms-searchbox" size=25 name="name" value="Gareth Roberts">
</form>

<script language ="javascript">
var image = '<img border="0" src=image.gif>';
var test1 = image.link("SearchView&amp;Query= "+ fullname +"&amp;SearchOrder=1&amp;Seq=1");
document.write(test1);
</script>

</body></HTML>

Kor
08-19-2005, 12:42 PM
try otherwise (but you must specify the full path of the page as variable fullpath:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<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 type="text/javascript">
var fullpath='http://mydomain.com/';
function goP(){
var fname=document.forms['tim'].elements['name'].value;
location.href = fullpath+'SearchView&amp;Query='+fname+'&amp;SearchOrder=1&amp;Seq=1';
}
</script>
</head>
<body>
<form name="tim">
<input title="Search the staff directory" style ="VERTICAL-ALIGN: 3px" display="inline" maxlength=255 class="ms-searchbox" size=25 name="name" value="Gareth Roberts">
</form>
<img border="0" src="image.gif" onclick="goP()">
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum