[solved] Select Box

here you will find only solved 1.1 Help topics

Moderator: 1.1 Moderators

[solved] Select Box

Postby dudeinmo on Wed Jan 27, 2010 10:48 pm

Ok, I originally had this in the 1.2 section, but it's a 1.1 question - I've got most the code - I just have to know how to disable an option in a select dropdown and enable that selection in another function. The below code on JSFIDDLE is what I have so far and it works to do what I need.
http://www.jsfiddle.net/F5sD9/4/

All I really need to know is how to disable the Royal option if Long Sleeve is selected. And if short sleeve is reselected the Royal option would show back up.

  1. <select class="inputboxattrib" id="Style_field" name="Style419">
  2.   <option value="Short_Sleeve">Short Sleeve</option>
  3.   <option value="Long_Sleeve">Long Sleeve</option>
  4. </select>
  5.  
  6. <select class="inputboxattrib" id="Color_field" name="Color419">
  7.   <option value="Black">Black</option>
  8.   <option value="Charcoal">Charcoal</option>
  9.   <option value="Navy">Navy</option>
  10.   <option value="Raspberry">Raspberry</option>
  11.   <option value="Teal">Teal</option>
  12.   <option value="Kelly">Kelly</option>
  13.   <option value="Red">Red</option>
  14.   <option value="Purple">Purple</option>
  15.   <option value="Orange">Orange</option>
  16.   <option value="Royal">Royal</option>
  17. </select>


  1. window.addEvent('domready', function() {
  2.     alert("The DOM is ready.");
  3.    
  4.     $('Style_field').addEvent('change', function(){
  5.        
  6.        
  7.        myStyle = $('Style_field').value;
  8.        
  9.        
  10.         if(myStyle == "Long_Sleeve"){
  11.         alert(myStyle);
  12.            
  13.  
  14.            
  15.         }else{
  16.        
  17.  
  18.        
  19.         }
  20.     });
  21. });
"You have to be the change you want to see in the world" - Ghandi
Rob Crowder Designs ( My Site )
MooTools 1.11 Docs
MooTools 1.11 Demos
User avatar
dudeinmo
 
Posts: 10
Joined: Wed Jan 27, 2010 6:56 pm
Location: Sugar Creek, MO

Re: Select Box

Postby dudeinmo on Wed Jan 27, 2010 11:37 pm

Solved my own coding problem .. works in 1.1.2 in jsfiddle anyway.

  1. window.addEvent('domready', function() {
  2.     alert("The DOM is ready.");
  3.     var royal = $('Color_field').getElement('option[value=Royal]');
  4.     $('Style_field').addEvent('change', function(){
  5.        
  6.        
  7.        myStyle = $('Style_field').value;
  8.        
  9.        
  10.         if(myStyle == "Long_Sleeve"){
  11.             alert(myStyle);
  12.  
  13.             royal.setAttribute('disabled',true);
  14.  
  15.         }else{
  16.        
  17.            royal.removeAttribute('disabled');
  18.        
  19.         }
  20.     });
  21. });
"You have to be the change you want to see in the world" - Ghandi
Rob Crowder Designs ( My Site )
MooTools 1.11 Docs
MooTools 1.11 Demos
User avatar
dudeinmo
 
Posts: 10
Joined: Wed Jan 27, 2010 6:56 pm
Location: Sugar Creek, MO


Return to Solutions

Who is online

Users browsing this forum: No registered users and 1 guest