By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 844 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

Simple question! Using text box value in a Ahref!

P: n/a
hi,
if i have a textbox (not in a form) on an html page and a link to
another page how can I use the textbox value when the link is clicked?

i.e.
<input type="text" name="T1" size="20">
<a href="abc" & t1.value>test link</a>

so if the textbox value was "def" the link when clicked would be abcdef

Jan 8 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Adrian said the following on 1/8/2006 12:28 PM:
hi,
if i have a textbox (not in a form) on an html page
A textbox not in a form? Odd.
Give your textbox a proper form. Or, an ID.
and a link to another page how can I use the textbox value when the link is clicked?
i.e.
<input type="text" name="T1" size="20">
<a href="abc" & t1.value>test link</a>

so if the textbox value was "def" the link when clicked would be abcdef


<a href="abc"
onclick="this.href=this.href+document.getElementBy Id('T1').value)">
Test Link</a>

Assuming you give it an ID of T1 also.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 8 '06 #2

P: n/a
Adrian wrote:
if i have a textbox (not in a form) on an html page and a link to
another page how can I use the textbox value when the link is clicked?

i.e.
<input type="text" name="T1" size="20">
<a href="abc" & t1.value>test link</a>

so if the textbox value was "def" the link when clicked would be
abcdef


<a href="abc"
onclick="this.href += document.forms[0].elements['T1'].value; return
true">
test link</a>
JW
Jan 8 '06 #3

P: n/a
Adrian wrote:
if i have a textbox (not in a form) on an html page and a link to
another page how can I use the textbox value when the link is clicked?


Put the text box in a form. Replace the link with a submit button. Style the
form to make it display inline. Style the submit button to make it look
like a link.

.... then it won't break if JavaScript isn't available or is turned off on
the client.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jan 8 '06 #4

P: n/a
Janwillem Borleffs said the following on 1/8/2006 12:36 PM:
Adrian wrote:
if i have a textbox (not in a form) on an html page and a link to
another page how can I use the textbox value when the link is clicked?

i.e.
<input type="text" name="T1" size="20">
<a href="abc" & t1.value>test link</a>

so if the textbox value was "def" the link when clicked would be
abcdef

<a href="abc"
onclick="this.href += document.forms[0].elements['T1'].value; return
true">
test link</a>


IE6:

document.forms.0.elements is null or not an object.

Mozilla:

Error: document.forms[0] has no properties

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 8 '06 #5

P: n/a
Thank you all for your help.
"Adrian" <Ad****@nospamhotmail.com.uk> wrote in message
news:dp**********@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com...
hi,
if i have a textbox (not in a form) on an html page and a link to
another page how can I use the textbox value when the link is clicked?

i.e.
<input type="text" name="T1" size="20">
<a href="abc" & t1.value>test link</a>

so if the textbox value was "def" the link when clicked would be abcdef

Jan 8 '06 #6

P: n/a
On 2006-01-08, Adrian <Ad****@nospamhotmail.com.uk> wrote:
hi,
if i have a textbox (not in a form) on an html page and a link to
another page how can I use the textbox value when the link is clicked?

i.e.
<input type="text" name="T1" size="20">
<a href="abc" & t1.value>test link</a>
so if the textbox value was "def" the link when clicked would be abcdef

<input type="text" id="T1" size="20">
<a
href="abc"
onclick="this.href+=document.getElementById('T1'). value"

test link</a>

should work on most recent browsers if javascript is enabled, else they'll
get "abc" as the link.
Bye.
Jasen
Jan 9 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.