Using jQuery to show/hide a field based on 2 dropdown fields

Using jQuery to show/hide a field based on 2 dropdown fields

Hi everyone,

Ive got a jQuery script which shows a SharePoint field based upon a dropdown value. This is great but I need to modify it so that I can show a field if 2 dropdown values are matched. Ive tried a few different ways but I cannot for the life of me get it to work.
Im only learning jQuery so am more than likely falling down here.

The current code to hide 1 or more SharePoint fields based on 1 dropdown is:

  1.  
  2. <!-- SECTION 1.0: SHOW 'RESPOND WITHIN 7 DAYS' OPTION -->
  3. // since we will be accessing the collection of nobr elements multiple times,
  4. // let's cache the collection for performance.
  5. var nobr;
  6. // define globally, set in document ready function (see below)

  7. function showConditionalRows(show) {
  8.     // set up an array with the display names of the conditional fields
  9.     var titles = ['Information request formally responded to within 7 days'];

  10.     for (var i = 0; i < titles.length; i++)
  11.         nobr.filter(":contains('" + titles[i] + "')").closest("tr").toggle(show);
  12. }

  13. // cache the 'STATUS' select control
  14. var sltStatus;

  15. $(document).ready(function() {
  16.     // initialize global vars
  17.     nobr = $("nobr");
  18.     sltStatus = $("select[title='Status']");

  19.     var val = sltStatus.val();
  20.     showConditionalRows(val == "Completed");
  21.     
  22.     // add code to update visibility of conditional rows when project status changes 
  23.     sltStatus.change(function() {
  24.        // if the value is "Completed", show all fields.
  25.         var val = $(this).val();
  26.         showConditionalRows(val == "Completed");
  27.     });
  28. });
So basically here, if 'STATUS' = ' Completed' then it shows the ' Information request formally responded to within 7 days' field. As I said, this works great, but.....

I would like to change the code so that if   'STATUS' = ' Completed' and 'PLANNED WORK' = 'Unplanned' then it shows the  ' Information request formally responded to within 7 days' field

Any help would be appreciated

Rick
-=djstylus=-