HighDots Forums  

how to append to URL ?

Javascript JavaScript language (comp.lang.javascript)


Discuss how to append to URL ? in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
brian
 
Posts: n/a

Default how to append to URL ? - 10-16-2003 , 10:07 PM






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 ?

Reply With Quote
  #2  
Old   
Stuart Palmer
 
Posts: n/a

Default Re: how to append to URL ? - 10-17-2003 , 03:09 AM






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 (AT) yahoo (DOT) com> wrote

Quote:
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 ?



Reply With Quote
  #3  
Old   
Stuart Palmer
 
Posts: n/a

Default Re: how to append to URL ? - 10-17-2003 , 03:22 AM



like:-

<a href="/0">Blah0</a>
<script language="javascript">
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.string.value;
return false;
}
</script>

<form name="test" onsubmit="return(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 (AT) youcant (DOT) com> wrote

Quote:
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 (AT) yahoo (DOT) com> wrote in message
news:af10786c.0310161807.64ed05f6 (AT) posting (DOT) google.com...
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 ?





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.