SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Dynamic Links

  1. #1
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dynamic Links

    Hi
    I have a form with several rows and each has a text box labeled 'Status'. The user should be able to change the value of Status, then click Save and a GET query will be run in an iframe without interrupting the browser window. To do this I am using a onkeydown event so the Save button's (which is an a href link) href address is changed to what is in the box. But I can't get the box's value to change!
    I have spent several hours at this now and I'm a bit exasperated. Could someone please take a look and tell me what I am doing wrong?

    The crucial bit is bold.

    Code:
    <form name='form4'>
    <input type=text size=8 name='4'
    value='' onkeydown="document.links['href4'].href == 'this.value'" 
    onchange="javascript:toggleLayer('saveenq4')">
    
    <style type="text/css">
    div#saveenq4{
      margin: 0px 20px 0px 20px;
      display: none;
    }
    </style>
    
    
    <div id="saveenq4">
    
      <a id="href4" target='RSIFrame'>Save</a>
    </div>
    
    <script type="text/javascript">
    function toggleLayer( whichLayer )
    {
      var elem, vis;
      if( document.getElementById ) // this is the way the standards work
        elem = document.getElementById( whichLayer );
      else if( document.all ) // this is the way old msie versions work
          elem = document.all[whichLayer];
      else if( document.layers ) // this is the way nn4 works
        elem = document.layers[whichLayer];
      vis = elem.style;
      // if the style.display value is blank we try to figure it out here
      if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
        vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
      vis.display = (vis.display==''||vis.display=='block')?'none':'block';
    }
    
    function handleResponse(a) {
      alert('enquiry ' + a)
    }
    
    function changeLink () {
      sel = document.addresses.list.selectedIndex;
      document.links[pos].href = document.addresses.list[sel].value;
    
    }
    </script>
    
    <iframe id="RSIFrame"
      name="RSIFrame"
      style="width:110px; height:110px; border: 0px"
      src="blank.html"></iframe>

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    onkeydown="document.getElementById('href4').href = this.value;"


  3. #3
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot!


Bookmarks

Posting Permissions

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