Disabling an input when certain criteria are met.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • punitshrivastava
    New Member
    • Jul 2007
    • 22

    Disabling an input when certain criteria are met.

    hello friends,
    i m working in php .i wsnt to know about feild validations .As i want to select data from combobox .according to that selected data feilds is to be editable Say for example :
    In combobox three values r to be filled .
    first name.
    last name
    age
    Now if we select first name then age & lastname feild should be disable.
    only firstname feild should be enable.
    similarly for two feilds.
    As we enter the value in respective feilds and search it it shows the complete data.respect to that feilds where we enter the data.
    As i m new fo php please tell me how i validatde the feilds.
    thanks
    punit
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Punit.

    I'm going to go ahead and move this thread to the JavaScript forum, where one of our resident Experts will be more likely to be able to help you out.

    Comment

    • epots9
      Recognized Expert Top Contributor
      • May 2007
      • 1352

      #3
      Originally posted by punitshrivastav a
      hello friends,
      i m working in php .i wsnt to know about feild validations .As i want to select data from combobox .according to that selected data feilds is to be editable Say for example :
      In combobox three values r to be filled .
      first name.
      last name
      age
      Now if we select first name then age & lastname feild should be disable.
      only firstname feild should be enable.
      similarly for two feilds.
      As we enter the value in respective feilds and search it it shows the complete data.respect to that feilds where we enter the data.
      As i m new fo php please tell me how i validatde the feilds.
      thanks
      punit
      well u can do it in php, but a better way would be to use javascript.

      to the drop down list add the attribute 'onchange', like this:
      [html]
      <select id="list" onchange="myFun ction(this.sele ctedIndex);">
      <!--options-->
      </select>
      [/html]

      in the javascript it would be

      [code=javascript]
      function myFunction(ddl)
      {
      //first option in drop down list "firstname"
      if(ddl == 0)
      {
      //enable
      //disable lastname, age
      }
      //lastname
      else if(ddl == 1)
      {
      //enable lastname
      //diable firstname, age
      }
      //nothing else, so its "age"
      else
      {
      //enable age
      //disable firstname, lastname
      }
      }
      [/code]

      try that out

      good luck

      Comment

      Working...