473,325 Members | 2,712 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,325 software developers and data experts.

Help with disable function in javascript

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 5033
acoder
16,027 Expert Mod 8TB
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
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...
4
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...
12
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
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() {...
2
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. ...
2
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...
6
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...
6
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
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...
8
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.