how to append to URL ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • brian

    how to append to URL ?

    user input accepted via a input in the form.
    this value needs to be appended to the current url (explained
    below)

    ie say present url is www.xyz.com and the user is asked
    to enter his string and say he enters "john"
    a hyper link needs to be created by appending this string, like
    <a href="http://www.xyz.com/john"></a>
    (the string "john" was the one input by the user in the input
    field)
    (where www.xyz.com is the current url)

    it is easy to extract the value of the input field entered by the user
    like document.forms[0].name1.value

    how to use this value and append to the current url and then create a
    new hyperlink with this appended string ?
  • Stuart Palmer

    #2
    Re: how to append to URL ?

    This may help:-


    this is to change all links, but if you know the position of th elink on
    your page you can just use it's 'i' number.

    Stu

    "brian" <brian_dell3@ya hoo.com> wrote in message
    news:af10786c.0 310161807.64ed0 5f6@posting.goo gle.com...[color=blue]
    > user input accepted via a input in the form.
    > this value needs to be appended to the current url (explained
    > below)
    >
    > ie say present url is www.xyz.com and the user is asked
    > to enter his string and say he enters "john"
    > a hyper link needs to be created by appending this string, like
    > <a href="http://www.xyz.com/john"></a>
    > (the string "john" was the one input by the user in the input
    > field)
    > (where www.xyz.com is the current url)
    >
    > it is easy to extract the value of the input field entered by the user
    > like document.forms[0].name1.value
    >
    > how to use this value and append to the current url and then create a
    > new hyperlink with this appended string ?[/color]


    Comment

    • Stuart Palmer

      #3
      Re: how to append to URL ?

      like:-

      <a href="/0">Blah0</a>
      <script language="javas cript">
      function appendlink()
      {
      // Change 2nd link link item in array (3rd on page, arrays start at 0)
      document.links[2].href= document.links[2].href + "/" +
      document.test.s tring.value;
      return false;
      }
      </script>

      <form name="test" onsubmit="retur n(appendlink()) ;">
      <input type="text" name="string">
      <input type="submit">
      </form>

      <a href="/1">Blah1</a><br />
      <a href="/2">Blah2</a> << This will be chnaged<br />
      <a href="/3">Blah3</a><br />
      <a href="/4">Blah4</a><br />
      <a href="/5">Blah5</a><br />
      <a href="/6">Blah6</a><br />

      "Stuart Palmer" <tryandspamme@y oucant.com> wrote in message
      news:JAMjb.31$6 E1.34832@newsfe p2-gui.server.ntli .net...[color=blue]
      > This may help:-
      > http://artlung.com/lab/scripting/change_all_links/
      >
      > this is to change all links, but if you know the position of th elink on
      > your page you can just use it's 'i' number.
      >
      > Stu
      >
      > "brian" <brian_dell3@ya hoo.com> wrote in message
      > news:af10786c.0 310161807.64ed0 5f6@posting.goo gle.com...[color=green]
      > > user input accepted via a input in the form.
      > > this value needs to be appended to the current url (explained
      > > below)
      > >
      > > ie say present url is www.xyz.com and the user is asked
      > > to enter his string and say he enters "john"
      > > a hyper link needs to be created by appending this string, like
      > > <a href="http://www.xyz.com/john"></a>
      > > (the string "john" was the one input by the user in the input
      > > field)
      > > (where www.xyz.com is the current url)
      > >
      > > it is easy to extract the value of the input field entered by the user
      > > like document.forms[0].name1.value
      > >
      > > how to use this value and append to the current url and then create a
      > > new hyperlink with this appended string ?[/color]
      >
      >[/color]


      Comment

      Working...