Jump to content

How To Append A Link


freakus_maximus

Recommended Posts

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.

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

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.
Link to comment
https://forums.phpfreaks.com/topic/13031-how-to-append-a-link/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.