Simple question! Using text box value in a Ahref!

A

Adrian

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
 
J

Janwillem Borleffs

Adrian said:
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
 
R

Randy Webb

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.getElementById('T1').value)">
Test Link</a>

Assuming you give it an ID of T1 also.
 
D

David Dorward

Adrian said:
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.
 
R

Randy Webb

Janwillem Borleffs said the following on 1/8/2006 12:36 PM:
Adrian said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top