I have a form in which a select field lists 5 items pus the option of "Other." I want a text field to be hidden unless the select field value is "Other."
The form is HTML, but I am assuming that I need to accomplish this with Javascript. Sample HTML code follows for the select field and the following text field. -
<td>Location:<br><select name="room_descr" size="1">
-
<option value="">Select a Location</option>
-
<option value="Patient Room">Patient Room</option>
-
<option value="Therapy Gym">Therapy Gym</option>
-
<option value="Cafeteria">Cafeteria</option>
-
<option value="Hospital Grounds">Hospital Grounds</option>
-
<option value="Hospital Contractor Site">Hospital Contractor Site</option>
-
<option value="Other">Other</option>
-
</select></td>
-
<td>Other:<br><INPUT TYPE=TEXT NAME="oth_descr" SIZE=32 MAXLENGTH=25></td>
-
I'm pretty new to HTML and to Javascript. I'd appreciate either an answer from this forum or some links to samples/reference books.
Thanks,
jej1216
3 1870 epots9 1,351
Recognized Expert Top Contributor
I have a form in which a select field lists 5 items pus the option of "Other." I want a text field to be hidden unless the select field value is "Other."
The form is HTML, but I am assuming that I need to accomplish this with Javascript. Sample HTML code follows for the select field and the following text field. -
<td>Location:<br><select name="room_descr" size="1">
-
<option value="">Select a Location</option>
-
<option value="Patient Room">Patient Room</option>
-
<option value="Therapy Gym">Therapy Gym</option>
-
<option value="Cafeteria">Cafeteria</option>
-
<option value="Hospital Grounds">Hospital Grounds</option>
-
<option value="Hospital Contractor Site">Hospital Contractor Site</option>
-
<option value="Other">Other</option>
-
</select></td>
-
<td>Other:<br><INPUT TYPE=TEXT NAME="oth_descr" SIZE=32 MAXLENGTH=25></td>
-
I'm pretty new to HTML and to Javascript. I'd appreciate either an answer from this forum or some links to samples/reference books.
Thanks,
jej1216
[html]
<td>Other:<br>< INPUT TYPE=TEXT NAME="oth_descr " SIZE=32 MAXLENGTH=25 disabled>
[/html]
and in your javascript -
document.oth_descr.disabled = false
-
if its in a form then -
document.myForm.oth_descr.disabled = false
-
thats should do the trick
[html]
<td>Other:<br>< INPUT TYPE=TEXT NAME="oth_descr " SIZE=32 MAXLENGTH=25 disabled>
[/html]
and in your javascript -
document.oth_descr.disabled = false
-
if its in a form then -
document.myForm.oth_descr.disabled = false
-
thats should do the trick
Thanks, epots9 - I understand where you set the text field to disabled and then override that with Javascript. Where do I put the Javascript? It needs to be following the "Other" option in the previous field, right?
I tried this but got errors: -
<td>Location:<br><select name="room_descr" size="1">
-
<option value="">Select a Location</option>
-
<option value="Patient Room">Patient Room</option>
-
<option value="Therapy Gym">Therapy Gym</option>
-
<option value="Cafeteria">Cafeteria</option>
-
<option value="Hospital Grounds">Hospital Grounds</option>
-
<option value="Hospital Contractor Site">Hospital Contractor Site</option>
-
<option value="Other">Other (Describe)
-
<script language="JavaScript">
-
document.irform.oth_descr.disabled = false;
-
</script></option>
-
</select></td>
-
<td>Other:<br><INPUT TYPE=TEXT NAME="oth_descr" SIZE=32 MAXLENGTH=25 disabled></td>
-
The form name is irform.
Thanks,
jej1216
epots9 1,351
Recognized Expert Top Contributor
put the javascript in the header
<script type="text/javascript">
function whatever()
{
//if option other is selected, enable textbox code
}
</script>
in the <select> tag add the attribute: [html]onchange="whate ver();"[/html]
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Michael Brennan-White |
last post by:
If I submit my for using a get action the resulting page loads . If I
use a post action I get an error page saying "The page cannot be
found". I am calling the originating page!!! This happens in IE as
well as FireFox.
This code has been tested on a Win2003 server, IIS6, PHP 5.0.3, mySQL
4.1.8 and it works fine.
The problem server is a Win2k server, IIS5, PHP 5.0.4, mySQL 4.1.11.
|
by: Steve Speirs |
last post by:
Hi
I'm trying to show/hide a simple piece of text and a text field on a
form based on what choice is made from a drop down box.
<select name="dropdown" size="1">
<option selected value="">Please make a selection</option>
<option value="1">Choice 1</option>
<option value="2">Choice 2</option>
<option value="3">Choice 3</option>
|
by: Lyn |
last post by:
Hi,
I am working on a genealogy form. The only table (so far) lists everybody
in the family, one record per person. Each record has an autonum ID.
The parent form (frmMainForm) displays the data in each record, which
includes the ID of the father and the mother (who also have records in the
table). One record per form.
I have a Tab Control in the form, and in one of the tabs I have a subform
(sfmSiblings) in which I wish to list...
|
by: Kathy |
last post by:
What is the standard technique for handling the fields in the following
scenario on a continuous form?
Multiple Divisions. Each Division has multiple Buildings. Each Building has
a Supervisor.
Tables: (abbreviated)
TblDivision
DivisionID
|
by: Susan Bricker |
last post by:
Greetings.
I am having trouble populating text data that represents data in my
table. Here's the setup:
There is a People Table (name, address, phone, ...)
peopleID = autonumber key
There is a Judge Table (information about judges)
judgeID = autonumber key
| |
by: my-wings |
last post by:
I think I've painted myself into a corner, and I'm hoping someone can help
me out.
I have a table of books (tblBooks), which includes a field (strPubName) for
Publisher Name and another field (strPubCity) for Publisher City. These two
fields have a many-to-one relationship with tables, (tlkpPubName and
tlkpPubCity) respectively. The lookup tables only have one field (strPubName
and strPubCity), which is their primary key.
I also have...
|
by: pic078 via AccessMonster.com |
last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files)
that remains stuck in task manager after exiting the application - you can't
reopen database after exiting as a result - I have read every post out there
and spent hours trying to figure out the problem with no success whatsoever -
I have constrained the problem to one form however, and I think it's hiding
somewhere in my code associated with this form, which is...
|
by: sorobor |
last post by:
dear sir ..
i am using cakephp freamwork ..By the way i m begener in php and javascript ..
My probs r bellow
I made a javascript calender ..there is a close button ..when i press close button then the calender gone actually i want if i click outside off the calender then it should me removed ..How kan i do this ...
Pls inform me as early as possible ..
I am waiting for ur quick replay ...Here i attached the source code ....
<!DOCTYPE...
|
by: steveninfl |
last post by:
Hello , I am using MS Access 2000. I have a Table called Transactions, I have created a form for this table, one of the fields on the form is a combo box with the row source type as value list. In this combo box field that I call "Transaction type" the user must select a value from the drop down list.
What I want to do is based on the selection of the "Transaction type" field, if the user should select a transaction type of ADHOC or...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |