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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.