I got a form and we changed the structure of how we are passing request variables from the jsp to the form bean. Anyway here is an example:
Before I was doing this
jsp:
<fieldset class="det">
<legend>Closure Level</legend>
<input type="checkbox" name="openLevel" >Open</input><br/>
<input type="checkbox" name="phyCompLevel" >Physically Complete</input><br/>
<input type="checkbox" name="finCompLevel" >Financially Complete</input>
</fieldset>
Handler:
if ((form.isOpenLevel() == true) && (form.isFinCompLevel() != true && form.isPhyCompLevel() != true))
{
paramBean.addFilter(new DetFilterCriteriaBean("PHYS_COMP_DATE ","is","NULL"));
}
if ((form.isPhyCompLevel() == true) && (form.isFinCompLevel() != true && form.isOpenLevel() != true))
{
paramBean.addFilter(new DetFilterCriteriaBean("PHYS_COMP_DATE ","is","NOT NULL"));
paramBean.addFilter(new DetFilterCriteriaBean("FIN_COMP_DATE","is","NULL"));
}
if ((form.isFinCompLevel() == true) && (form.isOpenLevel() != true && form.isPhyCompLevel() != true))
{
paramBean.addFilter(new DetFilterCriteriaBean("FIN_COMP_DATE","is","NOT NULL"));
}
As you can see I was checking which boxes were “checked” to see what to pass to the bean. We are pulling all the variables at once so I cant do any logic in the handler anymore. So what I need to so is do this same type of logic in Javascript as I submit the form. So something like this:
I need to do this condition in javascript:
if ((form.isOpenLevel() == true) && (form.isFinCompLevel() != true && form.isPhyCompLevel() != true))
{
<input type="hidden" name="filterCriteria('PHYS_COMP_DATE').fieldName" value="PHYS_COMP_DATE"/>
<input type="hidden" name="filterCriteria('PHYS_COMP_DATE').operation" value="is"/>
<input type="hidden" name="filterCriteria('PHYS_COMP_DATE').values" value="NULL"/>
}
If you can point me in the right direction..much appreciated. I dont need all the conditions, just that first one as an example.
In javascript, to validate if an input type=checkbox is checked, you use the
checkedattribute. Also, is preferable to use IDs to refer to an HTML’s element from javascript so you can take advantage of thegetElementById()function. Example using your code with a little modification: