alve
ho un problema con javascript ho un file html di questo tipo:
<html>
<head>
<title></title>
l
closeNodeDiv ();
makeCategory ('Dxxxs', 'chk_dept_012', '012');
makeCategory ('Cxxxxxion', 'chk_dept_016', '016');
openNodeDiv ();
makeNode ('Olxxxxxoley', 'chk_dept_016_user_odooley', '016', false);
closeNodeDiv ();
makeCategory ('Finaxxxmin', 'chk_dept_017', '017');
openNodeDiv ();
makeNode ('Erixxxxe', 'chk_dept_017_user_eclarke', '017', false);
makeNode ('Jennxxxxyle', 'chk_dept_017_user_jdoyle', '017', false);
makeNode ('Gexxxbson', 'chk_dept_017_user_ghobson', '017', false);
makeNode ('Paxxxella', 'chk_dept_017_user_pkinsella', '017', false);
makeNode ('Maxigan', 'chk_dept_017_user_mmadigan', '017', false);
makeNode ('Eixvern', 'chk_dept_017_user_emcgovern', '017', false);
makeNode ('Saxsh', 'chk_dept_017_user_swalsh', '017', false);
closeNodeDiv ();
makeCategory ('Huxrces', 'chk_dept_019', '019');
makeCategory ('Strxxxales', 'chk_dept_021', '021');
openNodeDiv ();
makeNode ('Rexbo', 'chk_dept_021_user_rakinyombo', '021', false);
makeNode ('Loxley', 'chk_dept_021_user_lclubley', '021', false);
makeNode ('Jox', 'chk_dept_021_user_jkelly', '021', false);
makeNode ('Prxkh', 'chk_dept_021_user_pkhukh', '021', false);
makeNode ('Susxe', 'chk_dept_021_user_smoore', '021', false);
makeNode ('Thexder', 'chk_dept_021_user_tteeder', '021', false);
makeNode ('Angxd', 'chk_dept_021_user_athind', '021', false);
closeNodeDiv ();
makeCategory ('Thxc', 'chk_dept_024', '024');
makeCategory ('Assexion', 'chk_dept_025', '025');
makeCategory ('Marketing', 'chk_dept_026', '026');
openNodeDiv ();
makeNode ('Naoxll', 'chk_dept_026_user_ncarroll', '026', false);
makeNode ('Grexolly', 'chk_dept_026_user_gconnolly', '026', false);
makeNode ('Juaxovez', 'chk_dept_026_user_jcordovez', '026', false);
makeNode ('Guyxher', 'chk_dept_026_user_gfletcher', '026', false);
makeNode ('Aoifxthuna', 'chk_dept_026_user_animhathuna', '026', false);
makeNode ('Inbxxxn', 'chk_dept_026_user_iosullivan', '026', false);
closeNodeDiv ();
makeCategory ('New Business Group', 'chk_dept_027', '027');
openNodeDiv ();
makeNode ('Isexxxey', 'chk_dept_027_user_icoffey', '027', false);
makeNode ('Jonxxxell', 'chk_dept_027_user_jcornwell', '027', false);
makeNode ('Emxxxll', 'chk_dept_027_user_eoneill', '027', false);
makeNode ('Jonxxes', 'chk_dept_027_user_jparkes', '027', false);
closeNodeDiv ();
makeCategory ('Skillxfe', 'chk_dept_031', '031');
openNodeDiv ();
makeNode ('Lexey', 'chk_dept_031_user_lcasey', '031', false);
makeNode ('Roxey', 'chk_dept_031_user_rcawley', '031', false);
closeNodeDiv ();
closeDiv();
closeTree();
}
</script>
<tr><td colspan="2" align="left">
<script language="JavaScript" type="text/javascript">
showDirectoryTree();
expandMenu('MI-1');
</script>
</td></tr>
<tr><td></td></tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
e due files javascript
il primo con le funzioni MakeNode che sono scritte sopra:
var Ccounter = 0;
var Mcounter = 1;
var firstNode = 0;
var lastNode = 0;
function beginDownload(newlocation) {
idl = 1;
if (location.search) {
idl = -location.search.indexOf("idl=n");
}
if (idl > 0) {
window.location = newlocation;
}
}
function openTree(caption)
{
document.write('<font face="Tahoma,Arial,Helvetica,Sans Serif" size="2">');
document.write('<div style="margin-left:0; display:;">');
document.write('<table cellpadding=0 cellspacing=0 border="0"><tr>');
document.write('<td valign=top><img src="images/tree_view/ftv2plastnode.gif" ID="MI-1" onClick="expandCollapseClick();">');
document.write('</td>');
document.write('<td valign=top><span ID="MT-1"><img src="images/epbulletsml.gif"> <font size="-1"><b>');
document.write(caption);
document.write('</b></font></span></td>');
document.writeln('</tr></table>');
}
function closeTree()
{
document.writeln ('</DIV>\n</FONT>');
}
// This function handles to onClick event for expanding/closing
// nodes of the tree.
function expandCollapseClick ()
{
var parentID;
var child;
var parentImage;
parentID = window.event.srcElement.id;
if (parentID.charAt (0) == 'M')
{
child = document.all ('C' + parentID.substr (2));
parentImage = document.all ('MI' + parentID.substr (2));
if (child.style.display == 'none') // hidden
{
child.style.display = '';
/* use last minus sign when appropiate */
if(parentID == 'MI-1' || parentID == 'MI-' + Mcounter)
parentImage.src = 'images/tree_view/ftv2mlastnode.gif';
else
parentImage.src = 'images/tree_view/ftv2mnode.gif';
}
else
{
child.style.display = 'none';
if(parentID == 'MI-1' || parentID == 'MI-' + Mcounter)
parentImage.src = 'images/tree_view/ftv2plastnode.gif';
else
parentImage.src = 'images/tree_view/ftv2pnode.gif';
}
}
}
// This function gets called from a script tag at the bottom of
// your html to expand the menu upon page opening.
function expandMenu(cat)
{
var parentID;
var child;
var parentImage;
// Get First level desired to expand. You want to specify
// Top level (MI-1) when calling this function.
parentID = cat.substr(0);
if (parentID.charAt(0) == 'M')
{
child = document.all ('C' + parentID.substr (2));
parentImage = document.all ('MI' + parentID.substr (2));
if (child.style.display == 'none') // hidden
{
child.style.display = '';
/* use last minus sign when appropiate */
if(parentID == 'MI-1' || parentID == 'MI-' + Mcounter)
parentImage.src = 'images/tree_view/ftv2mlastnode.gif';
else
parentImage.src = 'images/tree_view/ftv2mnode.gif';
}
else
{
child.style.display = 'none';
if(parentID == 'MI-1' || parentID == 'MI-' + Mcounter)
parentImage.src = 'images/tree_view/ftv2plastnode.gif';
else
parentImage.src = 'images/tree_view/ftv2pnode.gif';
}
}
}
// This function creates the link.
function makeLink (category, urlDir, targetc)
{
var categoryToDisplay, targetstr;
/*if (category.length > 12)
{
categoryToDisplay = category.substring (0, 50);
}
else
{
categoryToDisplay = category;
}
*/
HTMLstr='<font size="-1">' + category + '<input type="checkbox" name="' + urlDir + '" value="">';
return HTMLstr;
}
// This function creates the end nodes under any given category.
function makeNode (name, URLpath, targeta, checked)
{
++lastNode; // increment to track last node of node division.
if (checked == true)
{
document.writeln ('<table border="0" width="180" CELLPADDING=0 CELLSPACING=0><tr><td valign=top width=32><img ID=img1-' + lastNode + ' src="images/tree_view/ftv2vertline.gif"><img ID=img2-' + lastNode + ' src="images/tree_view/ftv2node.gif"></td><td valign=top style="font-size:11px;width:128px;"> ' + name + '</td><td valign=top width="20"><input type="checkbox" checked name="' + URLpath + '" value="" onClick="RM_deptcheck('+ targeta + ');"></td></tr></table>');
}
else
{
document.writeln ('<table border="0" width="180" CELLPADDING=0 CELLSPACING=0><tr><td valign=top width=32><img ID=img1-' + lastNode + ' src="images/tree_view/ftv2vertline.gif"><img ID=img2-' + lastNode + ' src="images/tree_view/ftv2node.gif"></td><td valign=top style="font-size:11px;width:128px;"> ' + name + '</td><td valign=top width="20"><input type="checkbox" name="' + URLpath + '" value="" onClick="RM_deptcheck(' + targeta + ');"></td></tr></table>');
}
}
// This function creates the category.
function makeCategory (name, URLpath, targetb)
{
Mcounter++;
document.writeln ('<table width="400" CELLPADDING=0 CELLSPACING=0><tr style="color:#FFFFFF;font-weight:bold;"><td valign=top width=16><IMG src="images/tree_view/ftv2pnode.gif" ID=MI-' + Mcounter + ' onClick=expandCollapseClick()></td><td style="font-size:12px;width:364px;background:#666666;padding-left:3px;" id="cat' + targetb + '"><SPAN ID=MT-' + Mcounter + '>' + name + '</SPAN></td><td valign="top" width="20" style="background:#666666;"><input type="checkbox" name="' + URLpath + '" value="" onClick="window.RM_SelectDept(' + targetb + ');window.RM_toggBg(' + targetb + ');"></td></tr></table>');
}
// This function creates the opening div tag for hiding and
// showing with the expandCollapseClick function.
function openDiv ()
{
Ccounter++;
document.writeln ('<DIV ID=C-' + Ccounter + ' STYLE="margin-left:15; display:None;">');
}
function openNodeDiv ()
{
firstNode = lastNode + 1; // remember first node of node division.
++Ccounter;
document.writeln ('<DIV ID=C-' + Ccounter + ' STYLE="margin-left:0; display:None;">');
}
// This function closes the div tag.
function closeDiv ()
{
var image;
document.writeln ('</DIV>');
image = document.all('MI-' + Mcounter);
image.src = 'images/tree_view/ftv2plastnode.gif';
// blank last catagory's node's first image(vertical line).
for(i = firstNode; i <= lastNode; ++i)
{
image = document.all('img1-' + i);
image.src = 'images/tree_view/ftv2blank.gif';
}
}
function closeNodeDiv ()
{
var image;
document.writeln('</DIV>');
image = document.all('img2-' + lastNode);
image.src = 'images/tree_view/ftv2lastnode.gif';
}
// This command calls the function created in the head of your
// document. If you do not want users to see your directory
// structure, you will need to put that function here. I moved
// it outside this file and into the head of the html file
// to manipulate the tree using ASP.
// showDirectoryTree();
il secondo lo inserisco come risposta
se provate a usare i tre files, gli ultimi due vanno nominati rispettivamente directory.js e toolbox.js non funzionano perfettamente, anzi se abilitate glia lert vedrete che i gruppi non corrispondono...
a me l'unica cosa che interessa e' che abilitando il checkbox di una sezione si abilitino anche i check di tutti i partecipanti della questione in esame
grazie
david
ho un problema con javascript ho un file html di questo tipo:
<html>
<head>
<title></title>
l
closeNodeDiv ();
makeCategory ('Dxxxs', 'chk_dept_012', '012');
makeCategory ('Cxxxxxion', 'chk_dept_016', '016');
openNodeDiv ();
makeNode ('Olxxxxxoley', 'chk_dept_016_user_odooley', '016', false);
closeNodeDiv ();
makeCategory ('Finaxxxmin', 'chk_dept_017', '017');
openNodeDiv ();
makeNode ('Erixxxxe', 'chk_dept_017_user_eclarke', '017', false);
makeNode ('Jennxxxxyle', 'chk_dept_017_user_jdoyle', '017', false);
makeNode ('Gexxxbson', 'chk_dept_017_user_ghobson', '017', false);
makeNode ('Paxxxella', 'chk_dept_017_user_pkinsella', '017', false);
makeNode ('Maxigan', 'chk_dept_017_user_mmadigan', '017', false);
makeNode ('Eixvern', 'chk_dept_017_user_emcgovern', '017', false);
makeNode ('Saxsh', 'chk_dept_017_user_swalsh', '017', false);
closeNodeDiv ();
makeCategory ('Huxrces', 'chk_dept_019', '019');
makeCategory ('Strxxxales', 'chk_dept_021', '021');
openNodeDiv ();
makeNode ('Rexbo', 'chk_dept_021_user_rakinyombo', '021', false);
makeNode ('Loxley', 'chk_dept_021_user_lclubley', '021', false);
makeNode ('Jox', 'chk_dept_021_user_jkelly', '021', false);
makeNode ('Prxkh', 'chk_dept_021_user_pkhukh', '021', false);
makeNode ('Susxe', 'chk_dept_021_user_smoore', '021', false);
makeNode ('Thexder', 'chk_dept_021_user_tteeder', '021', false);
makeNode ('Angxd', 'chk_dept_021_user_athind', '021', false);
closeNodeDiv ();
makeCategory ('Thxc', 'chk_dept_024', '024');
makeCategory ('Assexion', 'chk_dept_025', '025');
makeCategory ('Marketing', 'chk_dept_026', '026');
openNodeDiv ();
makeNode ('Naoxll', 'chk_dept_026_user_ncarroll', '026', false);
makeNode ('Grexolly', 'chk_dept_026_user_gconnolly', '026', false);
makeNode ('Juaxovez', 'chk_dept_026_user_jcordovez', '026', false);
makeNode ('Guyxher', 'chk_dept_026_user_gfletcher', '026', false);
makeNode ('Aoifxthuna', 'chk_dept_026_user_animhathuna', '026', false);
makeNode ('Inbxxxn', 'chk_dept_026_user_iosullivan', '026', false);
closeNodeDiv ();
makeCategory ('New Business Group', 'chk_dept_027', '027');
openNodeDiv ();
makeNode ('Isexxxey', 'chk_dept_027_user_icoffey', '027', false);
makeNode ('Jonxxxell', 'chk_dept_027_user_jcornwell', '027', false);
makeNode ('Emxxxll', 'chk_dept_027_user_eoneill', '027', false);
makeNode ('Jonxxes', 'chk_dept_027_user_jparkes', '027', false);
closeNodeDiv ();
makeCategory ('Skillxfe', 'chk_dept_031', '031');
openNodeDiv ();
makeNode ('Lexey', 'chk_dept_031_user_lcasey', '031', false);
makeNode ('Roxey', 'chk_dept_031_user_rcawley', '031', false);
closeNodeDiv ();
closeDiv();
closeTree();
}
</script>
<tr><td colspan="2" align="left">
<script language="JavaScript" type="text/javascript">
showDirectoryTree();
expandMenu('MI-1');
</script>
</td></tr>
<tr><td></td></tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
e due files javascript
il primo con le funzioni MakeNode che sono scritte sopra:
var Ccounter = 0;
var Mcounter = 1;
var firstNode = 0;
var lastNode = 0;
function beginDownload(newlocation) {
idl = 1;
if (location.search) {
idl = -location.search.indexOf("idl=n");
}
if (idl > 0) {
window.location = newlocation;
}
}
function openTree(caption)
{
document.write('<font face="Tahoma,Arial,Helvetica,Sans Serif" size="2">');
document.write('<div style="margin-left:0; display:;">');
document.write('<table cellpadding=0 cellspacing=0 border="0"><tr>');
document.write('<td valign=top><img src="images/tree_view/ftv2plastnode.gif" ID="MI-1" onClick="expandCollapseClick();">');
document.write('</td>');
document.write('<td valign=top><span ID="MT-1"><img src="images/epbulletsml.gif"> <font size="-1"><b>');
document.write(caption);
document.write('</b></font></span></td>');
document.writeln('</tr></table>');
}
function closeTree()
{
document.writeln ('</DIV>\n</FONT>');
}
// This function handles to onClick event for expanding/closing
// nodes of the tree.
function expandCollapseClick ()
{
var parentID;
var child;
var parentImage;
parentID = window.event.srcElement.id;
if (parentID.charAt (0) == 'M')
{
child = document.all ('C' + parentID.substr (2));
parentImage = document.all ('MI' + parentID.substr (2));
if (child.style.display == 'none') // hidden
{
child.style.display = '';
/* use last minus sign when appropiate */
if(parentID == 'MI-1' || parentID == 'MI-' + Mcounter)
parentImage.src = 'images/tree_view/ftv2mlastnode.gif';
else
parentImage.src = 'images/tree_view/ftv2mnode.gif';
}
else
{
child.style.display = 'none';
if(parentID == 'MI-1' || parentID == 'MI-' + Mcounter)
parentImage.src = 'images/tree_view/ftv2plastnode.gif';
else
parentImage.src = 'images/tree_view/ftv2pnode.gif';
}
}
}
// This function gets called from a script tag at the bottom of
// your html to expand the menu upon page opening.
function expandMenu(cat)
{
var parentID;
var child;
var parentImage;
// Get First level desired to expand. You want to specify
// Top level (MI-1) when calling this function.
parentID = cat.substr(0);
if (parentID.charAt(0) == 'M')
{
child = document.all ('C' + parentID.substr (2));
parentImage = document.all ('MI' + parentID.substr (2));
if (child.style.display == 'none') // hidden
{
child.style.display = '';
/* use last minus sign when appropiate */
if(parentID == 'MI-1' || parentID == 'MI-' + Mcounter)
parentImage.src = 'images/tree_view/ftv2mlastnode.gif';
else
parentImage.src = 'images/tree_view/ftv2mnode.gif';
}
else
{
child.style.display = 'none';
if(parentID == 'MI-1' || parentID == 'MI-' + Mcounter)
parentImage.src = 'images/tree_view/ftv2plastnode.gif';
else
parentImage.src = 'images/tree_view/ftv2pnode.gif';
}
}
}
// This function creates the link.
function makeLink (category, urlDir, targetc)
{
var categoryToDisplay, targetstr;
/*if (category.length > 12)
{
categoryToDisplay = category.substring (0, 50);
}
else
{
categoryToDisplay = category;
}
*/
HTMLstr='<font size="-1">' + category + '<input type="checkbox" name="' + urlDir + '" value="">';
return HTMLstr;
}
// This function creates the end nodes under any given category.
function makeNode (name, URLpath, targeta, checked)
{
++lastNode; // increment to track last node of node division.
if (checked == true)
{
document.writeln ('<table border="0" width="180" CELLPADDING=0 CELLSPACING=0><tr><td valign=top width=32><img ID=img1-' + lastNode + ' src="images/tree_view/ftv2vertline.gif"><img ID=img2-' + lastNode + ' src="images/tree_view/ftv2node.gif"></td><td valign=top style="font-size:11px;width:128px;"> ' + name + '</td><td valign=top width="20"><input type="checkbox" checked name="' + URLpath + '" value="" onClick="RM_deptcheck('+ targeta + ');"></td></tr></table>');
}
else
{
document.writeln ('<table border="0" width="180" CELLPADDING=0 CELLSPACING=0><tr><td valign=top width=32><img ID=img1-' + lastNode + ' src="images/tree_view/ftv2vertline.gif"><img ID=img2-' + lastNode + ' src="images/tree_view/ftv2node.gif"></td><td valign=top style="font-size:11px;width:128px;"> ' + name + '</td><td valign=top width="20"><input type="checkbox" name="' + URLpath + '" value="" onClick="RM_deptcheck(' + targeta + ');"></td></tr></table>');
}
}
// This function creates the category.
function makeCategory (name, URLpath, targetb)
{
Mcounter++;
document.writeln ('<table width="400" CELLPADDING=0 CELLSPACING=0><tr style="color:#FFFFFF;font-weight:bold;"><td valign=top width=16><IMG src="images/tree_view/ftv2pnode.gif" ID=MI-' + Mcounter + ' onClick=expandCollapseClick()></td><td style="font-size:12px;width:364px;background:#666666;padding-left:3px;" id="cat' + targetb + '"><SPAN ID=MT-' + Mcounter + '>' + name + '</SPAN></td><td valign="top" width="20" style="background:#666666;"><input type="checkbox" name="' + URLpath + '" value="" onClick="window.RM_SelectDept(' + targetb + ');window.RM_toggBg(' + targetb + ');"></td></tr></table>');
}
// This function creates the opening div tag for hiding and
// showing with the expandCollapseClick function.
function openDiv ()
{
Ccounter++;
document.writeln ('<DIV ID=C-' + Ccounter + ' STYLE="margin-left:15; display:None;">');
}
function openNodeDiv ()
{
firstNode = lastNode + 1; // remember first node of node division.
++Ccounter;
document.writeln ('<DIV ID=C-' + Ccounter + ' STYLE="margin-left:0; display:None;">');
}
// This function closes the div tag.
function closeDiv ()
{
var image;
document.writeln ('</DIV>');
image = document.all('MI-' + Mcounter);
image.src = 'images/tree_view/ftv2plastnode.gif';
// blank last catagory's node's first image(vertical line).
for(i = firstNode; i <= lastNode; ++i)
{
image = document.all('img1-' + i);
image.src = 'images/tree_view/ftv2blank.gif';
}
}
function closeNodeDiv ()
{
var image;
document.writeln('</DIV>');
image = document.all('img2-' + lastNode);
image.src = 'images/tree_view/ftv2lastnode.gif';
}
// This command calls the function created in the head of your
// document. If you do not want users to see your directory
// structure, you will need to put that function here. I moved
// it outside this file and into the head of the html file
// to manipulate the tree using ASP.
// showDirectoryTree();
il secondo lo inserisco come risposta
se provate a usare i tre files, gli ultimi due vanno nominati rispettivamente directory.js e toolbox.js non funzionano perfettamente, anzi se abilitate glia lert vedrete che i gruppi non corrispondono...
a me l'unica cosa che interessa e' che abilitando il checkbox di una sezione si abilitino anche i check di tutti i partecipanti della questione in esame
grazie
david