Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Drop down list box On Change event
Go
New
Search
Notify
Tools
Reply
  
[SOLVED] Drop down list box On Change event
 Login/Join
 
Gold member
posted
Hi,
I have a requirement that I developed the front end page on HTML Composer, it has a combo box that has values MONTH, YTD,R12, when Month selected 2 Calendars will be displayed to select start and end dates but when R12 selected these Calendars should be hide mode, I achieved this functionality using on change event as bellow, but my issue is when I go back to MONTH, Calendars are not appearing back, can some one tell me where I`m doing wrong

  
//Begin function combobox1_onchange
function combobox1_onchange(ctrl) {

	var combobox1 = document.getElementById("combobox1"); 
	var dropdown_value = combobox1_onchange.value; 

	var calendar1 = document.getElementById("calendar1"); 
	var calendar2 = document.getElementById("calendar2"); 

	IbComposer_showHtmlElement("text1", false);
	IbComposer_showHtmlElement("text8", false);
	IbComposer_showHtmlElement("calendar1", false);
	IbComposer_showHtmlElement("calendar2", false);

	if(dropdown_value == "MON"){
		//showing the appropriate elements
		IbComposer_showHtmlElement("text1", true);
		IbComposer_showHtmlElement("text2", true);
      IbComposer_showHtmlElement("calendar1", true);
      IbComposer_showHtmlElement("calendar2", true);
	}else if (dropdown_value == "R12"){
		//showing the appropriate elements
		IbComposer_showHtmlElement("text1", false);
		IbComposer_showHtmlElement("text2", false);
      IbComposer_showHtmlElement("calendar1", false);
      IbComposer_showHtmlElement("calendar2", false);
	}else if (dropdown_value == "YTD"){
		//showing the appropriate elements
		IbComposer_showHtmlElement("text1", false);
		IbComposer_showHtmlElement("text2", false);
      IbComposer_showHtmlElement("calendar1", false);
      IbComposer_showHtmlElement("calendar2", false);
	}
}
//End function combobox1_onchange

This message has been edited. Last edited by: FP Mod Chuck,


WebFocus-8/Windows/HTML, PDF, EXCEL
 
Posts: 89 | Registered: September 20, 2010Reply With QuoteReport This Post
Master
posted Hide Post
Don't you need the if statement to look for "MONTH" not "MON"?

Also, the variable dropdown_value should equal combobox1.value;

Try the code below:
  
//Begin function combobox1_onchange
function combobox1_onchange(ctrl) {
    var combobox1 = document.getElementById("combobox1");
    //var dropdown_value = combobox1_onchange.value;
    var dropdown_value = combobox1.value;

    var calendar1 = document.getElementById("calendar1");
    var calendar2 = document.getElementById("calendar2");

    IbComposer_showHtmlElement("text1", false);
    IbComposer_showHtmlElement("text8", false);
    IbComposer_showHtmlElement("calendar1", false);
    IbComposer_showHtmlElement("calendar2", false);

    //if (dropdown_value == "MON") {
    if (dropdown_value == "MONTH") {
        //showing the appropriate elements
        IbComposer_showHtmlElement("text1", true);
        IbComposer_showHtmlElement("text2", true);
        IbComposer_showHtmlElement("calendar1", true);
        IbComposer_showHtmlElement("calendar2", true);
    } else if (dropdown_value == "R12") {
        //showing the appropriate elements
        IbComposer_showHtmlElement("text1", false);
        IbComposer_showHtmlElement("text2", false);
        IbComposer_showHtmlElement("calendar1", false);
        IbComposer_showHtmlElement("calendar2", false);
    } else if (dropdown_value == "YTD") {
        //showing the appropriate elements
        IbComposer_showHtmlElement("text1", false);
        IbComposer_showHtmlElement("text2", false);
        IbComposer_showHtmlElement("calendar1", false);
        IbComposer_showHtmlElement("calendar2", false);
    }
}
//End function combobox1_onchange

This message has been edited. Last edited by: Hallway,


Hallway
WF(Prod):8202M
WF(Test):8202M
OS/Platform:Win 10
Outputs:All
 
Posts: 540 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Or simplified since you already hide the controls/elements that you don't want to be displayed by default you only need to test the condition to show them.
And as Hallway pointed out, you need to test the proper value.

//Begin function combobox1_onchange
function combobox1_onchange(ctrl) {
//showing the appropriate elements
    IbComposer_showHtmlElement("text1", false);
    IbComposer_showHtmlElement("text8", false);
    IbComposer_showHtmlElement("calendar1", false);
    IbComposer_showHtmlElement("calendar2", false);

    if (combobox1.value == "MONTH") {
        IbComposer_showHtmlElement("text1", true);
        IbComposer_showHtmlElement("text2", true);
        IbComposer_showHtmlElement("calendar1", true);
        IbComposer_showHtmlElement("calendar2", true);
    }
}
//End function combobox1_onchange

This message has been edited. Last edited by: MartinY,


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2282 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Even shorter:
function combobox1_onchange(ctrl) {
    // I think the assignment of combobox1 got lost in Martin's example, but ctrl should be a usable reference for the same.
    var show = (ctrl.value == "MONTH");

    IbComposer_showHtmlElement("text1", show);
    IbComposer_showHtmlElement("text8", show);
    IbComposer_showHtmlElement("calendar1", show);
    IbComposer_showHtmlElement("calendar2", show);
}


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1655 | Location: Enschede, Netherlands | Registered: August 12, 2010Reply With QuoteReport This Post
Gold member
posted Hide Post
Thank you Hallway,

it worked halfway when I changed to combobox1.value, calendar box is hiding but not calendar icon, icon is still visible when I select R12 or YTD, is their any way I can hide the calendar icon also.

Thanks,
Krishna


WebFocus-8/Windows/HTML, PDF, EXCEL
 
Posts: 89 | Registered: September 20, 2010Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Something that I had to used to show/hide the calendar image, but can't remember with which version of WF (probably an early version of WF8) and doesn't seems to be anymore an issue with at least v8201M

// This function is to hide the calendar icon which is not hidden when hiding the calendar control
function hideCalendarIcon() {
	//get all images on the page into array
	images=document.getElementsByTagName("img");
	//get the number of images in array
	numImages = images.length;
	
	//Loop through images and see if it is a dynCalendar
	for (i=0;i<numImages;++i) {
  		if (images[i].src.indexOf("dynCalendar.gif")>0){
		//If it is, hide
   			images[i].style.visibility='hidden';
		}
	}
}

// This function is to show the calendar icon
function showCalendarIcon() {
	//get all images on the page into array
	images=document.getElementsByTagName("img");
	//get the number of images in array
	numImages = images.length;
	
	//Loop through images and see if it is a dynCalendar
	for (i=0;i<numImages;++i) {
  		if (images[i].src.indexOf("dynCalendar.gif")>0){
		//If it is, show
   			images[i].style.visibility='visible';
		}
	}
}


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2282 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Wep Good One


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2282 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Drop down list box On Change event

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.