1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Javascript Dynamic link

Discussion in 'JavaScript' started by roseplant, Jun 25, 2007.

  1. #1
    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.

    
    
    <form name='form4'>
    <input type=text size=8 name='4'
    value='' [B]onkeydown="document.links['href4'].href == 'this.value'" [/B]
    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>
    
    Code (markup):
     
    roseplant, Jun 25, 2007 IP
  2. roseplant

    roseplant Peon

    Messages:
    253
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Figured it out!
     
    roseplant, Jul 9, 2007 IP
  3. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #3
    In which case the idea is that you explain how you did it.
     
    Logic Ali, Jul 9, 2007 IP
  4. roseplant

    roseplant Peon

    Messages:
    253
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Sure mate, didn't realise anyone was interested. I was using a double equals instead of single. And the single quotes were a problem so I got rid of them (otherwise the href would be set to literally "this.value"). The corrected bit is :


    onkeydown="document.links.href4.href = this.value"
     
    roseplant, Jul 12, 2007 IP