Jump to content


How To Append A Link

  • Please log in to reply
1 reply to this topic

#1 freakus_maximus

  • Members
  • PipPipPip
  • Advanced Member
  • 177 posts

Posted 27 June 2006 - 04:47 PM

I have this bit of code which will update the href with whatever is typed in the box (and navigated away from) using an onchange event. This is just a test script to get the function down.

    <script type="text/javascript">
  function update()
     document.getElementById("link").href = document.f.s.value;
    <form name="f" ID="Form1">
        <INPUT id="Text1" type="text" name="s" onchange="update();">
        <a href="link1.php" id="link">Link</a>

This works fine, but not exactly what I need it to do.

My real form has an input field that receives a date from a date picker, no problems there. This date is to be used as a variable in the href. But I cannot seem to figure out how to append the date selected to the href.

So basically, my initial href value is (and will always be) "link1.php?datecompleted=" and I need it to be onchange "link1.php?datecompleted=06-27-06". (The formmated value 06-27-06 is all handled by the date picker when it dumps it into the input field.)

Any ideas or help? I am a newb to javascript, so go easy.

#2 nogray

  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 27 June 2006 - 05:21 PM

let's say the date variable is called "dt"

document.getElementById("link").href = "link1.php?datecompleted="+dt;


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users