help javascript

patefit77

Nuovo Utente
7 Giu 2006
2
0
0
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">&nbsp;<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;">&nbsp;' + 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;">&nbsp;' + 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
 

patefit77

Nuovo Utente
7 Giu 2006
2
0
0
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=280,height=250');");
}

// adds zeros in front of a string to make the string [length] length
function leading_zero(arg, length) {
var strArg = new String(arg);

while (strArg.length < length) {
strArg = "0" + strArg;
}
return (strArg);
}

// checks or un-checks a checkbox
function checkit(formname, elementname) {
if (document.forms[formname].elements[elementname].checked == true) {
document.forms[formname].elements[elementname].checked = false;
return false;
} else {
document.forms[formname].elements[elementname].checked = true;
return true;
}
}

function changeButton(mode, formname, elementname) {
if (mode == true) {
// button text NEXT
document.forms[formname].elements[elementname].value = "Next >>";
} else {
// button text is DONE
document.forms[formname].elements[elementname].value = "Done";
}


}

function ValidateForm(id)
{
var i=0;
for(i=0;i<document.forms[id].elements.length;i++) {
if (document.forms[id].elements.value =="") {
alert("Please enter data in all fields");
return false;
}
if (document.forms[id].elements.name == "studPassword") {
if (document.forms[id].studPassword.value !== document.forms[id].studPassword2.value) {
alert("Password fields do not match");
return false;
}
}
}
return true;
}

function hide(obj) {
if (document.all) {
document.all[obj].style.visibility = 'hidden';
}
else if(document.layers) {
document.layers[obj].display = 'hidden';
}
else if(document.getElementById) {
node = document.getElementById(obj).style.visibility = 'hidden';
}
}

function showfrms(id) {
if (document.all) {
document.all['BB_frm_Group'].style.visibility = 'hidden';
document.all['BB_frm_Loc'].style.visibility = 'hidden';
document.all['BB_frm_All'].style.visibility = 'hidden';
document.all[id].style.visibility = 'visible';
}
}

function RM_StatusBar(txt) {
if (txt=='') {
window.status='';
}
else
{
window.status=':::Click To ' + txt + ':::';
}
}

function ShowLayer(obj,arg) {
var i=1;
if (document.all) {
for(i=1;i<=arg;i++){
eval("window.document.all['mod"+i+"'].style.visibility='hidden';");
}
window.document.all[obj].style.visibility='visible';
}
else if (document.layers) {
for(i=1;i<=arg;i++) {
eval("window.doument.layers['mod"+i+"'].visibility='hidden';");
}
window.document.layers[obj].visibility='visible';
}
else if (document.getElementById) {
for(i=1;i<=arg;i++) {
node = eval("window.document.getElementById('mod"+i+"').style.visibility='hidden';");
}
node = window.document.getElementById(obj).style.visibility='visible';
}
}

var color = '';
var fgcolor = '';

function RM_mOver(obj) {
if (document.all) {
window.color = window.document.all[obj].style.background;
//window.fgcolor = window.document.all[obj].style.color;
window.document.all[obj].style.background = '#008FB3';
//window.document.all[obj].style.color = '#FFCC00';
}
else {
if (document.layers){
window.color = window.document.layers[obj].bgcolor;
//window.fgcolor = window.document.layers[obj].fgcolor;
window.document.layers[obj].bgcolor = '#008FB3';
//window.document.layers[obj].fgcolor = '#FFCC00';
}
else {
if (document.getElementById){
window.color = window.document.getElementById(obj).style.background;
//window.fgcolor = window.document.getElementById(obj).style.color;
node = window.document.getElementById(obj).style.background = '#008FB3';
//node = window.document.getElementById(obj).style.color = '#FFCC00';
}
else {
alert("aggggghhhh");
}
}
}
}


function RM_mOut(obj) {
if (document.all) {
window.document.all[obj].style.background = window.color;
//window.document.all[obj].style.color = window.fgcolor;
}
else {
if (document.layers) {
window.document.layers[obj].bgcolor = window.color;
//window.document.layers[obj].fgcolor = window.fgcolor;
}
else {
if (document.getElementById) {
node = window.document.getElementById(obj).style.background = window.color;
//node = window.document.getElementById(obj).style.color = window.fgcolor;
}
}
}
}

function SortRecs(arg,obj) {
var myString;
myString = new String(arg);
document.forms[obj].SortBy.value = myString;
document.forms[obj].submit();
}

function TOCheck() {
alert("Your Session Has Expired!\nPlease Click OK And Log In Again.");
}

function RM_PrntChk(arg1,arg2) {
if ((arg1==0) && (arg2==0)) {
alert("Please choose a Section before attempting to print.");
}
else {
eval("window.open('pr_reports.asp?RprtType=" + arg1 + "&Cls=" + arg2 + "','new_win')");
}
}

function RM_SelectDept(arg) {


var strArg = new String(leading_zero(arg, 3));
/*

var strElmnt;
var objElmnt;
objElmnt = eval("document.forms['frmGroup'].elements['chk_dept_" + strArg + "']");

for (i=0;i<document.forms['frmGroup'].elements.length;i++) {
strElmnt = new String(document.forms['frmGroup'].elements.name);
if (strElmnt.substr(0,13) == "chk_dept_" + strArg + "_") {
document.forms['frmGroup'].elements.checked = objElmnt.checked;
}
} */

}


function RM_deptcheck(arg) {

var strArg = new String(leading_zero(arg, 3));

alert("Department checked is: "+strArg);

/*
var objElmnt = eval("document.forms['frmGroup'].elements['chk_dept_" + strArg + "']");
var strElmnt;
var x=0;
var y=0;
var z=0;
// loop through each form object

for(i=0;i<document.forms['frmGroup'].elements.length;i++) {
strElmnt = new String(document.forms['frmGroup'].elements.name);

if (strElmnt.substr(0,13) == "chk_dept_" + strArg + "_") {
z += 1;
if (document.forms['frmGroup'].elements.checked == true) {
x += 1;
} else {
y += 1;
}
}
}

if (x==z) {
objElmnt.checked = true;
RM_toggBg(strArg);
} else {
objElmnt.checked = false;
var strTmp = eval("window.document.all['cat" + strArg + "'].style.background");
if (strTmp == '#006699') {
eval("window.document.all['cat" + strArg + "'].style.background = '#666666'");
}
}*/

}

function RM_toggBg(id) {

alert(id);

/*var rowcolor;
var row = 'cat' + new String(leading_zero(id, 3));


rowcolor = window.document.all[row].style.background;
if (rowcolor == '#006699') {
window.document.all[row].style.background = '#666666';
}
else {
window.document.all[row].style.background = '#006699';
}*/
}
 
Discussioni simili
Autore Titolo Forum Risposte Data
simgia [Javascript] Google maps help! Javascript 1
F Help array da javascript a php Javascript 2
E [Javascript] help me !!! array da php a java Javascript 9
A Help Script in Javascript (sono molto insesperto) Javascript 0
C [HELP] interazione flash e javascript Flash 0
M Errore Javascript visualizzazione sito: HELP! Javascript 5
S help javascript Javascript 0
M html con inerzia javascript..non funge..help Javascript 0
N Help Javascript Vi Prego!!!! Javascript 1
A help con uno javascript Javascript 1
K Help Javascript Javascript 0
C Problemi interazione Flash-javascript!!!! Help! Flash 1
M Help for Linux Bash Programmazione 1
E Help Sql somma orari PHP 32
P Passare i risultati di un foreach in un modal. Help! PHP 2
J help me C/C++ 1
K Help: problema con uno script di booking in php! PHP 0
Q HELP ME PLEASE!‼️‼️ E-Commerce 1
L difficoltà con Xampp. printing php mancante...help Web Server 6
K [PHP] Help me a problem... Pleases PHP 1
S Problemi con modulo upload video php (help!) PHP 0
M HELP FORM CREATO IN PHP PHP 14
M Help - consultare (ed esportare) dati da un DB pubblico mySql PHP 2
S [PHP] help me!! PHP 2
F Cerco contatto tipo help-desk Offerte e Richieste di Lavoro e/o Collaborazione 2
F Help-PDO copiare Database MySQL PHP 3
Andrea1981 [WordPress] [HTML] Help modifica credits nel footer.Tema Customizr. WordPress 5
S [WordPress] Footer php - il background riempie tutta la pagina - help WordPress 1
A funzioni asincrone e callback...help! Ajax 10
M [PHP] Help: controllo valori inseriti in un campo PHP 1
P Help con js/php PHP 6
N Sistema di Help di Delphi 7 non funziona su Win10 Windows e Software 0
silvia88 ***Help*** - Anteprima immagine photoshop diversa da file Photoshop 3
A HELP: vedo il sito posizionato in serp solo con i tool di posizionamento!!! SEO e Posizionamento 3
T [PHP] Calcolo anzianità soggetti [era: Help me :( Esercizio per me impossibile] PHP 9
trattorino Creare codice php help PHP 26
CoyotesSon [PHP] Help! Creazione di una finestra PHP 5
V help java Java 2
L help me Presentati al Forum 0
L N00b need help Webdesign e Grafica 2
I Help - Problema installazione tema di themeforest WordPress 1
claudiav ciao!! help.. Presentati al Forum 0
Z Invio mail da telecamere HIKVision - HELP!!! IP Cam e Videosorveglianza 0
M - WordPress - Sito Annunci HELP ME!!!! :crying: WordPress 2
L Hosting, help HTML e CSS 2
M HoneyPot su macchina virtuale HELP ME PLEASE!!! Reti LAN e Wireless 0
F Help con leaseweb Hosting 2
M DropDownList HELP ASP.NET 8
N Query lenta, help ! MySQL 0
P Help! modifica script Javascript 11

Discussioni simili