Ok, I did my research and I tried various solutions to no avail.
I have little or no knowledge of JSP and this internship required me to troubleshoot this Javascript bug.
Implementation : It is a simple select all implementation. When the parent checkbox is toggled, all the child elements are toggled as well.
Any help is highly appreciated. Thank you.
This is the actual Javascript code :
[CODE]
function Commodity(oThis) {
var p=0;
if (this.document.searchform.Commodity!= null) {
for(p=0; p<this.document.searchform.Commodity.length;p++) {
if (this.document.searchform.Commodity[p].value == oThis.value) {
this.document.searchform.Commodity[p].checked = oThis.checked;
break;
}
}
}
for (var i = 0; i < this.document.searchform.Engine.length; i++) {
if(this.document.getElementById(this.document.searchform.Engine[i].value) == null) {
if (this.document.searchform.Engine[i].key == oThis.value) {
if (this.document.searchform.Commodity[p].checked){
this.document.searchform.Engine[i].checked = true;
this.document.searchform.Engine[i].disabled = true;
} else {
this.document.searchform.Engine[i].checked = false;
this.document.searchform.Engine[i].disabled = false;
}
}
}
}
}
function Supplier(oThis) {
if (this.document.searchform.Engine.length != null) {
for (var i = 0; i < this.document.searchform.Engine.length; i++) {
if (this.document.searchform.Engine[i].value == oThis.value &&
this.document.searchform.Engine[i].key == oThis.key) {
this.document.searchform.Engine[i].checked = oThis.checked;
break;
}
}
} else {
if (this.document.searchform.Engine.value == oThis.value &&
this.document.searchform.Engine.key == oThis.key) {
this.document.searchform.Engine.checked = oThis.checked;
}
}
}
This is the search.do code (HTML below)
[CODE]
<div id=”m_1″ class=”modbox” portletid=”3″ style=”left: 0px; top: 0px;”>
<div class=”modtitle”>
<h2 id=”m_1_link” class=”lnk”>
<input type=”checkbox” title=”” onclick=”Commodity(this)” value=”3″ name=”Commodity”/>
<span id=”m_1_title” class=”modtitle_text” title=”Test One” style=”cursor: pointer;”> Test One</span>
</h2>
<a id=”m_1_zippy” class=”minbox” title=”Minimize” href=”#” onclick=”chgTT(this);return _zm(‘1’);return false;”/>
<div id=”m_1_h” class=”dt” title=”Test One” style=”cursor: move;”/>
</div>
<div id=”m_1_b” class=”modboxin”>
<input type=”checkbox” key=”3″ value=”4″ name=”Engine” onclick=”javascript:Supplier(this)”/>
<span>Grainger</span>
<br/>
<input type=”checkbox” key=”3″ value=”472″ name=”Engine” onclick=”javascript:Supplier(this)”/>
<span>Local Catalog1</span>
<br/>
<input type=”checkbox” key=”3″ value=”477″ name=”Engine” onclick=”javascript:Supplier(this)”/>
<span>Local Catalog6</span>
<br/>
<input type=”checkbox” key=”3″ value=”478″ name=”Engine” onclick=”javascript:Supplier(this)”/>
<span>Local Catalog7</span>
<br/>
<input type=”checkbox” disabled=”disabled”/>
<span>
</span>
<br/>
</div>