473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Simple question! Using text box value in a Ahref!

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
6 1472
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Trimbitas Sorin | last post by:
Hello I have a simple syntax question : What does the following line mean: 1: %checkType; ?? I know that @test="" is an array and $test="" is a simple variable. Thank you With best regards...
3
by: Patchwork | last post by:
Hi Everyone, Please take a look at the following (simple and fun) program: //////////////////////////////////////////////////////////////////////////// ///////////// // Monster Munch, example...
13
by: Jason Swett | last post by:
I want to do graphics with C++. Surprisingly, so far nobody has been able to tell me anything helpful. How do I do it? Any input would be greatly appreciated. Jason
2
by: Raskolnikow | last post by:
Hi! I have a very simple problem with itoa() or the localtime(...). Sorry, if it is too simple, I don't have a proper example. Please have a look at the comments. struct tm *systime; time_t...
7
by: abcd | last post by:
I am trying to set up client machine and investigatging which .net components are missing to run aspx page. I have a simple aspx page which just has "hello world" printed.... When I request...
2
by: Allain Bøge | last post by:
It is really a simple question. Visual Basic .NET (2003) I create 2 forms (Form1 and Form2) I create a checkbox in Form1 (checkbox1) I create a checkbox in Form2 (checkbox1) I go to Form1...
4
by: pcnerd | last post by:
I originally asked this question in the "classic" VB forum. It occured to me after I had sent it that I sent it to the wrong forum. Anyway! Here's the situation. I have VB.NET 2005 Express...
1
by: wildheart | last post by:
Hi everyone, I am creating a webpage that is designed for friends and family and i wanted to create a Question based login that by answering the question correctly you can gain access. So for...
6
by: beantaxi | last post by:
Hello all, I'm looking for a very simple code analysis tool. I have a large codebase to analyze, and all I really need to do is to find all uses of all methods in a few interfaces. Many tools...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.