Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

HTMLB and Javascript: Dependent Checkboxes

Hello Collegues,

i try to programming a search component with some dependent checkboxes. For example the user should check "checkbox 1" and there should be "checkbox 2" also selected.

I write this small example for this. But it dont works. I thing i have an mistake in the onClientClick function. Does somebody knows the right way to do this?

public class SearchLocalization extends AbstractPortalComponent
    public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
		//response.write("Javascript Checkbox Test<br>");	
		IPageContext myContext = PageContextFactory.createPageContext(request, response);
		if (myContext == null) {
			response.write("myContext == null");
		Form myForm = myContext.createFormDocument("Javascript Checkbox Test");	
		GridLayout gl = new GridLayout();		
		Checkbox one = new Checkbox("one");
		Checkbox two = new Checkbox("two");
		two.setOnClientClick("javascript:one.checked = true;");		

Best regards,



Hi Patrick,

Try replacing the error line as

two.setOnClientClick("javascript: " +

"var funcName = htmlb_formid+\"_getHtmlbElementId\";" +

" func = window[funcName];" +

" var one = eval(func(\"one\"));" +

" var two = eval(func(\"two\"));" +

" var twostatus = two.getChecked();" +

" if(twostatus==true){" +

"one.setChecked(true); }");

This works for me in a dynpage.

Hope that will help in Abstract Portal Component also.


Harini S

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question