473,804 Members | 4,288 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with disable function in javascript

3 New Member
HI. I have a dropdown menu named arrivalcity (options are Rome, Naples, Palermo, and CAtania).
I also have 4 other dropdown menus which have departure dates for those cities.

Basically I want those 4 dropdown menus disabled by default. Then based on which arrivalcity
option they choose only one of those 4 dropdown menus gets enabled so they can select the departure date from the appropriate menu.
I know this can get accomplished in javascript, but I don't know where to start. Please help. I'm getting desperate to accomplish this.


The following is what I have so far:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function selChk(obj) 
  3. {
  4.              var rome_dep = document.getElementById('arrivaldate_rome');
  5.             var naples_dep = document.getElementById('arrivaldate_rome');
  6.             var palermo_dep = document.getElementById('arrivaldate_rome');
  7.             var catania_dep = document.getElementById('arrivaldate_rome');
  8.  
  9.       if(obj.value!= 'nose1') 
  10.               {
  11.                 if (obj.value = 'rome')
  12.                 {
  13.                  rome_dep.disabled = false;
  14.                     naples_dep.disabled = true;
  15.                    palermo_dep.disabled = true;
  16.                     catania_dep.disabled = true;
  17.                 }
  18.                 else if (obj.value = 'naples')
  19.                 {
  20.                  rome_dep.disabled = true;
  21.                     naples_dep.disabled = false;
  22.                    palermo_dep.disabled = true;
  23.                     catania_dep.disabled = true;
  24.                 } 
  25.                 else if (obj.value = 'palermo')
  26.                 {
  27.                  rome_dep.disabled = true;
  28.                     naples_dep.disabled = true;
  29.                    palermo_dep.disabled = false;
  30.                     catania_dep.disabled = true;
  31.                 } 
  32.                 else
  33.                 {
  34.                  rome_dep.disabled = true;
  35.                     naples_dep.disabled = true;
  36.                    palermo_dep.disabled = true;
  37.                     catania_dep.disabled = false;
  38.                 } 
  39.  
  40.        else 
  41.        {
  42.  
  43.             rome_dep.disabled = true;
  44.             naples_dep.disabled = true;
  45.             palermo_dep.disabled = true;
  46.             catania_dep.disabled = true;
  47.  
  48.        }
  49.  
  50. }
  51. </script>
  52.  
  53. <html>
  54. <body>
  55. <select name="arrivalcity" size="1" id="arrivalcity" maxlength="25" ononchange="selChk(this);">
  56.                                 <option value="nose1">please select</option>
  57.  
  58.                                 please select
  59.                               <option value="Rome">Rome</option>
  60.                               <option value="Naples">Naples</option>
  61.                               <option value="Palermo">Palermo</option>
  62.                               <option value="Catania">Catania</option>
  63.                               <option value="Other">Other</option>
  64.                                                         </select>
  65. </body>
  66. </html>
  67.  
Any help would greatly be appreciated. Thanks!
Mar 30 '09 #1
1 5060
acoder
16,027 Recognized Expert Moderator MVP
Perhaps you only want to show one at a time (for that, use the style.display property - "block" to show and "none" to hide.

If you want to show all of them at once but some disabled, in your code Naples, Palermo and Catania are getting the same object as Rome!
Mar 31 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
4816
by: Derek | last post by:
Hi, I've built a rather large CGI that dumps a lot of data and a fairly complex javascript app out to the client's browser. Granted this may be poor style according to someone web design philosophy but that is the way things need to work for now here. The problem I'm having is that it appears that the browsers (IE, mozilla and netscape) are sometimes getting confused about wether the javascript code is running. By this I mean when I...
4
56679
by: KS | last post by:
Im trying to prevent the user from clicking any other links on my page when the user have selected/clicked a href once. Sometimes it takes a while before the next page loads so some user will try clicking other links or the same link. I can prevent this when i use buttons by calling onclick and in a javascript getElementsByTagName("input") and then check the type to be type of "button" or "submit" which i then disable. It works. This also...
12
8899
by: Forti2ude | last post by:
Hello, I have a simple form... <form> <select name="foo" multiple> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select>
1
5855
by: Fluffy Convict | last post by:
Does anybody know how to disable only certain options of an option list by a javascript function? With the following function you can disable a option list completely: function disableList() { var x=document.getElementById("myOptionList") x.disabled=true }
2
13278
by: techfuzz | last post by:
I scoured this group and others looking for the best way to disable a button after the first click to prevent multiple submissions, but never did find anything that worked like they said it would. I went ahead and wrote my own bit of code so I'm sharing it here for everyone. Even though it doesn't really disable the button by greying it out, it prevents the multiple submissions which it what I was attempting to prevent all along. ...
2
2064
by: blarfoc | last post by:
Hi, I have to disable a button on a aspx page after the user clicks it. I have to disable the button with javascript because the process takes 20 seconds to run the full course. I kno I need to do this with javascript but I do not kno how. Please tell me if you will please.
6
1914
by: drec | last post by:
I am just learning Javascript and I would like to create a basic form that gives me two options. This will be using either checkbox or radio input type, however I would like the second option to allow the user to type in a value. Also, I would like the 2nd option only editable if the button for that option is selected. All I can seem to find is basic examples of forms, and none of which have this feature. The form would look something...
6
10138
by: ron | last post by:
1. Can I disable a user control in a web page? 2. Can I disable the 'close' function on the top-right corner of a popup window, so I can use code-behind function to close the browser?
0
5578
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
8
2054
by: Richard Maher | last post by:
Hi, I am in a mouseup event for button A and I'd like to disable=false button B before starting some work. Is there anyway that an event for button B can then fire before my event processing for button A's mouseup has completed? I beleive event processing to be single-threaded for good reason but I need a "stop" button and it's no good if it doesn't do anything until the other processing has finished :-)
0
10593
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, 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...
0
10340
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
10329
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
10085
tracyyun
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...
0
9163
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...
0
6858
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
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3000
bsmnconsultancy
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...

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.