×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Activate dropdown2 or dd3 based on value of dd1

Activate dropdown2 or dd3 based on value of dd1

Activate dropdown2 or dd3 based on value of dd1

(OP)
New to Brio & javascript, have written reports, need to develop an EIS interface for users to run reports.  Have dropdown list with 3 limit options.  If all option (default) is select then run report1.  If emp option selected make droopdown2 visible, select emp name then run report2.  If client option selected.. the same.  Would like an example of if..else statement to activate & populate other dropdowns.
Also a recommendation for a good reference book on javascript would be helpful.

RE: Activate dropdown2 or dd3 based on value of dd1

If the "All" selection is made just execute the call for the report 1 that you referred to:
(in code below "//" is JavaScript character set that "comments out" documentation and programming comments)



//This code would be in the script section of the OnSelection event of the first dropdown

var choice = ActiveDocument.Sections["EIS"].Shapes["ddReportOptions"].SelectedIndex
var valuex = ActiveDocument.Sections["EIS"].Shapes["ddReportOptions"].Item(choice)
if (choice==1) {     
// User selects "All"  ....  ignore the restriction on the result set
// ( this means that "All" must always be the first option)

  ActiveDocument.Sections["Results"].Limits["Persons"].Ignore = true
// Note - you can also restrict the query limit if you process it again
  ActiveDocument.Sections["Default Report 1"].PrintOut();
}
else
{
// the user has selected the emp or client option, so expose the second dropdown and
// allow the user to choose the individual to  limit  the report to :

   ActiveDocument.Sections["EIS"].Shapes["ddTwo"].Visible=true
}


// Then add this code to the OnSelection event of the second drop down and
// call report 2:

   ActiveDocument.Sections["Results"].Limits["Persons"].Ignore = false
   ActiveDocument.Sections["Results"].Limits["Persons"].SelectedValues.RemoveAll()
   var valuesct = ActiveDocument.Sections["EIS"].Shapes["ddTwo"].SelectedList.Count

   for (x=1;  x<=valuesct; x++)
      {
        var values = ActiveSection.Shapes["ddTwo"].SelectedList[x]
        ActiveDocument.Sections["Results"].Limits["Persons"].SelectedValues.Add(values)
      }
        ActiveDocument.Sections["Default Report 2"].PrintOut()

____________________________________________________________________

// Here's an example of using a "Case Select" type evaluation that sometimes
// comes in handy also:


limitName = 'BrioValue'
switch (ddReportSelect.SelectedIndex) {
    case 2:    updateLimits('emp') // this will pass the parameter "emp" to the limit named BrioValue
        break
    case 3:    updateLimits('client') // this will change the value to "client"
        break
    default:    ignoreLimits() // this is the default, obviously Case 1, which is usually "ALL"
        break
}

//The "switch"  has called for one of the two functions below:
// ---------- functions ----------
function updateLimits(newValue) {
    with (ActiveDocument.Sections["Main Query"]) {
        for (var i = 1; Limits.Count; i++) {   // loop through all limits
            if (Limits.DisplayName == limitName) {
                Limits.SelectedValues.RemoveAll()
                Limits.SelectedValues.Add(newValue)
                Limits.Ignore = false
                break
            }
        }
    }

}

function ignoreLimits() {
    with (ActiveDocument.Sections["Main Query"]) {
        for (var i = 1; Limits.Count; i++) {   // loop through all limits
            if (Limits.DisplayName == limitName) {
                Limits.Ignore = true
                break
            }
        }
    }

}


As far as reference books, I can't say specifically, but I have always used the SAMS (publisher) "Learn It in 21 Days" books as a place to start - they are written with good examples and aren't cluttered with a lot of author ramblings of anecdotes or non-programming material. I don't know if they have one for JavaScript - you'll have to check online with vendors or check the local bookstore. Hope this helps! Good luck!

RE: Activate dropdown2 or dd3 based on value of dd1

(OP)
Thanks, this is helpful. I chose the "simple" version but.. dd2 isn't responding.  No values are displayed, nor is the report defaulted to with all the values printed.  This is the problem I was having with my own code.  I deleted all code thru out the app & used your sample.  I must be missing punctuation. Also, I'd like the users to be able to view the report online & choose to print it later.  My script is below


Script OutPut


// drop down 2 -- Consultant is a computed field (last & first names concatenated)
--Document: EISMain: ConsultantDropDown: OnSelection
ActiveDocument.Sections["ReportsTable"].Limits["Consultant"].Ignore=false
ActiveDocument.Sections["ReportsTable"].Limits["Consultant"].SelectedValues.RemoveAll()
var valuect =ActiveDocument.Sections["EISMain"].Shapes["ConsultantDropDown"].SelectedList.Count

for (x=1;  x<=valuect; x++)
{
var values = ActiveSection.Shapes["ConsultantDropDown"].SelectedList[x]
ActiveDocument.Sections["ReportsTable"].Limits["Consultant"].SelectedValues.Add(values);
}
ActiveDocument.Sections["ByConsultantReport"].PrintOut();


// drop down 1
--Document: EISMain: SelectOptionDropDown: OnSelection
var choice = ActiveDocument.Sections["EISMain"].Shapes["SelectOptionDropDown"].SelectedIndex
var values = ActiveDocument.Sections["EISMain"].Shapes["SelectOptionDropDown"].Item(choice)
if (choice==1) {
ActiveDocument.Sections["ReportsTable"].Limits["Consultant"].Ignore = true
ActiveDocument.Sections["AllProjectsReport"].PrintOut();
}
else
{
ActiveDocument.Sections["EISMain"].Shapes["ConsultantDropDown"].Visible=true;
}

RE: Activate dropdown2 or dd3 based on value of dd1

I think we're accessing the wrong value. If the drop down (ConsultantDropDown)is only going to give you one value to send to the report limit, then you just assign this value to the limit:
__________________________________________________
ActiveDocument.Sections["ReportsTable"].Limits["Consultant"].Ignore=false
ActiveDocument.Sections["ReportsTable"].Limits["Consultant"].SelectedValues.RemoveAll()


var values = ActiveDocument.Sections["EIS"].Shapes["ConsultantDropDown"].Item(ActiveDocument.Sections["EIS"].Shapes["ConsultantDropDown"].SelectedIndex)

ActiveDocument.Sections["ReportsTable"].Limits["Consultant"].SelectedValues.Add(values)
____________________________________________
If you are going to allow more than one selection, then you'll have to use a list box instead of a drop down, and then we would need to utilize a loop to add more than one limit value.

To debug you can use an alert statement to find out where the code is stopping (see below):

Alert("Here")

This will display a pop-up box with "Here" if the preceeding code executed properly. You can continue to move the location of this statement between runs to find out where the code is stopping.
Also, make sure that the visible property of the second dropdown is set to false before you run the application, and back to false when you exit the section or want to allow another choice.

Sorry for the confusion - let me know if this works!

RE: Activate dropdown2 or dd3 based on value of dd1

I also forgot about your preview requirement - just activate the report section instead of calling the print function - the user can use the print command from a toolbar when they want a hard copy.

RE: Activate dropdown2 or dd3 based on value of dd1

(OP)
I had picked up on the list box vs drop down and adjusted one of my test scripts.  It still didn't help.  The alert method showed that I'm not moving the focus to the 2nd box.  I've  simplfid the process.  I have only 2 drop down boxes.  The 1st is the consultant.  I changed from the computed column, consultant, to the db column, last name.  And added the last names as custom values. The user will be alllowed to select only 1 last name. I still am not getting my value passed to the limit, however the limit is being created

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close