Jump to content


Photo

disable field based on drop down


  • Please log in to reply
1 reply to this topic

#1 laxplayin24

laxplayin24
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 25 May 2006 - 01:52 PM

I was wondering if it is possible to disable certain fields in a from based on which drop down is selected. If so could someone help me out i've been looking on the web and haven't found anything. Thanks.

#2 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 25 May 2006 - 05:34 PM

You'll need to set a javascript function to disable and enable fields when the select menu is changed.

The select menu will look something like this
<select onChange="disable_fields(this.value);">
<option value="....">....</option>
</select>

In your javascript add a function -disable_fields()
function disable_fields(val){
     if (val == "...."){
          // disabling the field
          document.getElementById('field_id').disabled = true;
     }
     else {
          // enabling the field
          document.getElementById('field_id').disabled = false;         
     }
}

NoGray.com





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users