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

    Variable in HTML Link

    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>

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    try otherwise (but you must specify the full path of the page as variable fullpath:
    PHP Code:
    <!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> 
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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