Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Activate dropdown2 or dd3 based on value of dd1

Status
Not open for further replies.

JLB50

IS-IT--Management
Jul 5, 2002
3
US
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.
 
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[&quot;ddTwo&quot;].SelectedList[x]
ActiveDocument.Sections[&quot;Results&quot;].Limits[&quot;Persons&quot;].SelectedValues.Add(values)
}
ActiveDocument.Sections[&quot;Default Report 2&quot;].PrintOut()

____________________________________________________________________

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


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

//The &quot;switch&quot; has called for one of the two functions below:
// ---------- functions ----------
function updateLimits(newValue) {
with (ActiveDocument.Sections[&quot;Main Query&quot;]) {
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[&quot;Main Query&quot;]) {
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) &quot;Learn It in 21 Days&quot; 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!
 
Thanks, this is helpful. I chose the &quot;simple&quot; 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[&quot;ReportsTable&quot;].Limits[&quot;Consultant&quot;].Ignore=false
ActiveDocument.Sections[&quot;ReportsTable&quot;].Limits[&quot;Consultant&quot;].SelectedValues.RemoveAll()
var valuect =ActiveDocument.Sections[&quot;EISMain&quot;].Shapes[&quot;ConsultantDropDown&quot;].SelectedList.Count

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


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

 
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[&quot;ReportsTable&quot;].Limits[&quot;Consultant&quot;].Ignore=false
ActiveDocument.Sections[&quot;ReportsTable&quot;].Limits[&quot;Consultant&quot;].SelectedValues.RemoveAll()


var values = ActiveDocument.Sections[&quot;EIS&quot;].Shapes[&quot;ConsultantDropDown&quot;].Item(ActiveDocument.Sections[&quot;EIS&quot;].Shapes[&quot;ConsultantDropDown&quot;].SelectedIndex)

ActiveDocument.Sections[&quot;ReportsTable&quot;].Limits[&quot;Consultant&quot;].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(&quot;Here&quot;)

This will display a pop-up box with &quot;Here&quot; 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!
 
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.
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top