473,385 Members | 1,893 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,385 software developers and data experts.

How Can an <input> tag be made visible or hidden dynamically

I'm trying to make an input tag visible or hidden based on the value of
another input tag, so that when the 1st input tag is changed in anyway, the
2nd input tag will become visible.

Thanks in advance,

Rick
Aug 18 '06 #1
4 18406
In article <Jb***************@newssvr14.news.prodigy.com>,
Rick <ri*****@ccpspeople.comwrote:
>I'm trying to make an input tag visible or hidden based on the value of
another input tag, so that when the 1st input tag is changed in anyway, the
2nd input tag will become visible.
It needs javascript onKeyUp and onKeyDown methods and some CSS.

CSS: ==================================================

..hide { display: none; }
..show { display: inline; }

HTML: =================================================

<!-- this is your "sensing" input field -->
<input type="text" name="sense" value=""
onKeyDown="showhidden(this.form.sense,this.form.re veal);"
onKeyUp="showhidden(this.form.sense,this.form.reve al);" >

<!-- this is your initially-hidden input field -->
<input type="text" name="reveal" value="" class="hide">

Javascript in your HTML <headblock: ==================

<script language="JavaScript" type="text/javascript>
function showhide(fieldname,hiddenname)
{
hiddenname.className = fieldname.length ? "show" : "hide";
}
</script>

Note: I have not tested anything I wrote above. But it should get you
started.

-Alex
Aug 19 '06 #2
Rick <ri*****@ccpspeople.comscripsit:
I'm trying to make an input tag visible or hidden based on the value
of another input tag, so that when the 1st input tag is changed in
anyway, the 2nd input tag will become visible.
(Apparently you mean that the content of an input element is changed. Users
don't change tags; only authors do when they edit a document.)

It should be obvious that you cannot do this in HTML. If it isn't obvious to
you, then you haven't understood what HTML. It's a poor lonesome data
format.

What you should look for depends on what you are doing and what you wish to
accomplish. You haven't given the slightest clue about this.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Aug 19 '06 #3
Hey! Be nice to people. Maybe this chap doesn't know as much about
HTML as you. And maybe he's a brain surgeon seeking relaxation.
Bitterness is its own "reward." Congratulations.

Aug 19 '06 #4
On Sat, 19 Aug 2006 00:45:43 +0000 (UTC), ax**@spamcop.net (axlq) wrote:
>In article <Jb***************@newssvr14.news.prodigy.com>,
Rick <ri*****@ccpspeople.comwrote:
>>I'm trying to make an input tag visible or hidden based on the value of
another input tag, so that when the 1st input tag is changed in anyway, the
2nd input tag will become visible.

It needs javascript onKeyUp and onKeyDown methods and some CSS.
Or maybe the onChange method, depending on exactly what the OP has in
mind.

Don't forget to test that the result is still usable (if less elegant)
when Javascript is disabled.

--
Stephen Poley

http://www.xs4all.nl/~sbpoley/webmatters/
Aug 19 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jonathan Daggar | last post by:
Hello, I'm trying to put together a form with a very tight table formatting. However, every time I put an text-type input field in, the browser pads the area to the right of it with space. I've...
2
by: not 2 swift | last post by:
I thought I would update an old page on which I had used a <INPUT TYPE=image ...> with a <BUTTON><IMG SRC=...></BUTTON> The problem is that <BUTTON> always provides a shadow/emboss effect. Can...
3
by: TR | last post by:
Is it possible with CSS to prevent this wrapping alignment with a checkbox with a nested label? This is the label of the checkbox that wraps beneath it I'd prefer it looked like...
3
by: Ben | last post by:
Here's my form: <form name="aForm" method='post'> <input type=file name=file1 onkeypress='KeyPress()'><br> <a id='attachMoreLink' href='javascript:AddFileInput()">Attach More Files </a> <input...
5
by: Bart van Deenen | last post by:
Hi all I have a form with a couple of input fields, embedded within spans. I am using script.aculo.us for dragging and dropping, and want to reorder the input fields that way. The input fields are...
2
by: Richard Maher | last post by:
Hi, I'm trying to use the Visibility Style attribute for a Div to effectively PopUp a lightweight window with some additional context-sensitive information, when a user mouses over a given...
2
by: Sreenath Rao Nellutla | last post by:
Hai all, I am trying to create dropdown calendar control with HTML input control by writing JavaScript. But while executing I am getting the error as "Error on Page" on the status bar of the...
1
by: test9991014 | last post by:
Hi folks, I've got something like this: <table> <tr> <td>1</td> <td align=center> <input type=text> </td>
8
by: Zhang Weiwu | last post by:
hello. Is it possible to design CSS in the way that content in <inputare not visible in print out (a.k.a. value of <inputnot visible) while the border remain visible? trial: input {...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.