473,802 Members | 2,468 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Display 2nd Textbox when option selected

I have a select box with about 5 options.
I need to have one of the options, when selected, display a second select
box.
The second select box is populated by a database and needs to be preloaded
so the page doesnt refresh.

How can this be done?

I guess could have the second select box displayed but disabled and it would
become active once the option is selected on the first select box.

I just have no idea how to do this.

Thanks in advance!


Jul 23 '05 #1
2 2598


Targa wrote:
I have a select box with about 5 options.
I need to have one of the options, when selected, display a second select
box.
The second select box is populated by a database and needs to be preloaded
so the page doesnt refresh.

How can this be done?

I guess could have the second select box displayed but disabled and it would
become active once the option is selected on the first select box.

I just have no idea how to do this.


HTML 4 knows an attribute named disabled for HTML form controls, it is
scripted as the property of the same name so to have a form that enables
a select if a certain option of another select is selected have a look
at the following example:

<html>
<head>
<title>disablin g/enabling a form control</title>
</head>
<body>
<form name="formName" >
<select name="select1"
onchange="if (this.selectedI ndex == 3) {
this.form.eleme nts.select2.dis abled = false;
}
else {
this.form.eleme nts.select2.dis abled = true;
}">
<option>optio n 1</option>
<option>optio n 2</option>
<option>optio n 3</option>
<option>optio n 4</option>
<option>optio n 5</option>
</select>
<select name="select2">
<option>optio n 1</option>
<option>optio n 2</option>
<option>optio n 3</option>
<option>optio n 4</option>
<option>optio n 5</option>
</select>
<script type="text/javascript">
document.forms. formName.elemen ts.select2.disa bled = true;
</script>
</form>
</body>
</html>

Note that script is used to disable the select initially as a select
disabled statically with HTML would mean the user needs JavaScript
enabled to make use of the form.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2
Excellent example!
Worked perfectly for me - Thanks!
"Martin Honnen" <ma*******@yaho o.de> wrote in message
news:40******@o laf.komtel.net. ..


Targa wrote:
I have a select box with about 5 options.
I need to have one of the options, when selected, display a second select box.
The second select box is populated by a database and needs to be preloaded so the page doesnt refresh.

How can this be done?

I guess could have the second select box displayed but disabled and it would become active once the option is selected on the first select box.

I just have no idea how to do this.


HTML 4 knows an attribute named disabled for HTML form controls, it is
scripted as the property of the same name so to have a form that enables
a select if a certain option of another select is selected have a look
at the following example:

<html>
<head>
<title>disablin g/enabling a form control</title>
</head>
<body>
<form name="formName" >
<select name="select1"
onchange="if (this.selectedI ndex == 3) {
this.form.eleme nts.select2.dis abled = false;
}
else {
this.form.eleme nts.select2.dis abled = true;
}">
<option>optio n 1</option>
<option>optio n 2</option>
<option>optio n 3</option>
<option>optio n 4</option>
<option>optio n 5</option>
</select>
<select name="select2">
<option>optio n 1</option>
<option>optio n 2</option>
<option>optio n 3</option>
<option>optio n 4</option>
<option>optio n 5</option>
</select>
<script type="text/javascript">
document.forms. formName.elemen ts.select2.disa bled = true;
</script>
</form>
</body>
</html>

Note that script is used to disable the select initially as a select
disabled statically with HTML would mean the user needs JavaScript
enabled to make use of the form.
--

Martin Honnen
http://JavaScript.FAQTs.com/


Jul 23 '05 #3

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

Similar topics

4
1978
by: kindermaxiz | last post by:
//I have a form such as this: echo "<form method=\"post\" action=$php_self> <BR><INPUT TYPE=\"TEXT\" NAME=\"textbox\" SIZE=\"40\"> <BR> <select name=\"searchlist\"> <option value=\"val1\">$x</option> <option value=\"val2\">$y</option> <option value=\"val3\">$z</option> <option value=\"val4\">$t</option> </select> <p> <input type=\"submit\" name=\"submit_the_values\" value=\"$submit\">
19
6936
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the JavaScript in this code from a couple different sites but I'm not 100% sure what each line is doing...This is the ASP code that I'm using for the page....Take a look at the JavaScript code and please let me know what each line is doing....I have been...
3
18591
by: Iain Hallam | last post by:
Hi. I've been using display:none on the style property of some <option> elements in my forms, which works fine with Mozilla - as expected it removes the option from my dropdown (although it still exists in the code). Is there an equivalent in IE? The reasoning behind this is that I want users to rank objects using a <select> for each place (see below), and to remove the choice of earlier objects from <select> drop-downs later in the...
2
7054
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs, input box for units of service, description of the service and each row has its own dropdown list of unit fees that apply. Each dynamically created row will return 3 values fee1_choice, fee1_unit and fee1_money. Note The above informaton is...
1
2326
by: Bobc003 | last post by:
Hi, I'd like to put a double drop-down menu on my webpage and instead of a redirection to a new webpage, I'd like to display the result in a new section. I'm kind of stuck and I only have a triple menu here. Here an exemple of what I need. (menu)Size, (menu) color and then display the price somewhere in a box. Thanks a bunch Bob
7
3490
by: TechnoAtif | last post by:
Hi..There is again a similar problem..Now i;ve got the option values of list?menu box to show the textbox. If the option value of list is yes then the textbox is to be displayed . Can anyone help..through php or javascript. ONe more thing..How can i perform the same function for more than one such kind of problem..I mean if there is any other place in the form where i have to display textbox on selecting a particular value.how can it be...
5
3432
by: =?Utf-8?B?R1ROMTcwNzc3?= | last post by:
Hi Guys, It's been a while, I've got a small problem that I could do with your expertise on. As you know (I Think) I build websites for recruitment agencies, part of the website includes a job board facility and for job form entry I used a normal form with a normal textbox, however what I'm finding now is that a lot of recruitment consultants are pasting the job description into the textbox, which when submitted is resulting in most of...
2
3689
by: kurtzky | last post by:
i created a form that should function as follows: i will enter a number in a textbox..then it should query from the database all the records which has that number..these records will have a different item no in it..then, these records will be saved in a temporary datatable (which i made in a separate class, the name is WBASKET)...The item nos of these records will be displayed in a combobox, say item1, item2, etc.. then,i have a datagrid...
1
2423
by: angelicdevil | last post by:
i have listbox 1 which displays status , based on selection of status listbox 2 displays usernames. and based on username selected the textbox displays the email id. its working fine till displaying user names in listbox 2 based on selected of status in listbox. but its not displaying the emailid based on selection of usernames and when i click on search for users button its refreshs the page and shows the intial page also want the text box...
0
9562
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,...
0
10303
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 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...
1
10282
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9111
agi2029
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...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6838
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();...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4270
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
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.