cancel
Showing results for 
Search instead for 
Did you mean: 

HTMLB and JavaScript

Former Member
0 Kudos

Hi,

I am using HTMLB in my JSP page.Is there any way to hide or show the HTMLB components when the page is loaded, like HTML onLoad() calling javascript.

expecting some sample code from HTMLB experts.really i stuck wih this problem for 2 days.

For example.....i have one DropdownList box.Based on the selected dropdown values ,i need to show and hide one InputField and another Dropdown.

Regds,

Jeyanth

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

You can achive this in two ways.

1) client side :

Have the dynamic fields in style sheet.Sho or hide based on the value selected.

Please find below code:

In your drop down list box : mention onclientselect = dispaly()

<SPAN ID=ss Style="Visibility:hidden;

Filter:revealTrans(duration=0)">

<!-- Your field --!>

</SPAN>

<-Javascript>

function display()

{

if ( vlaue ==1 )

{

ss.style.visibility = "visible";

}

else

{

ss1.style.visibility = "visible";

ss.style.visibility = "hidden";

// ss1 is style sheet 2 where in which ur second field is placed

}

}

the above code may cause some problem in netscape browsers. But it can be resolve by handling stylesheet properly.

2) Server side:

in the dropdown mention onselect = display()

in your dynpage class mention display() method.

Have two variables in bean for each field.

set those fields hide or show based on the value.

Put your field

<%

if ( flag == true )

{

your field 1

}

else

{

your field 2

}

Former Member
0 Kudos

Hi Anto,

For example you initially displayed Dropdownlist DDLIST and two input fields INPUT1 & INPUT2 using HTMLB Controls in JSP.

Assume that you want to display INPUT1 when 1st option in DDLIST is selected and display INPUT2 when Secon Option in DDLIST is selected. When 3 option is selected wat to display both INPUT & INPUT2.

Now, create a bean class to hold the selected value from DDLIST. Reference your Bean class in the JSP and update the Attribute of the bean class based on DDLIST selection. Now, use if conditions to display whatever control you want to display in the JSP.

Hope this helps.

-Suresh