JS enables dynamic cascading scoring with unlimited series

Source: Internet
Author: User

1 35
1.1 10
1.2 10
1.3 10
1.3.1 5
1.3.2 5
1.4 5
2 30
2.1 10
2.2 20

Total: 65

----------------------------------------------------

// Initialize the parent Self-Rating
Function setfathernum ()
{
VaR objtable = Document. getelementbyid ("dgrdlist ");
// Divide the parent-level self-evaluation into 0 Points
For (VAR I = objtable. Rows. Length-2; I> 0; I --)
{
VaR stritemnum1 = objtable. Rows [I]. cells [1]. innertext;
VaR arrayitemnum = stritemnum1.split (".");
VaR arraycount = arrayitemnum. length;
If (arraycount> 1)
{
VaR itemnum = "";
For (VAR n = 0; n <= arrayCount-2; n ++)
{
Itemnum + = "." + arrayitemnum [N];
}

Itemnum = itemnum. substring (1, itemnum. Length );

For (var j = objtable. Rows. Length-2; j> 0; j --)
{
VaR idsum1 = parsefloat (j) + parsefloat (1 );
VaR zptextid1 = "dgrdlist _ CTL" + idsum1 + "_ selfappraisenum ";

VaR stritemnum2 = objtable. Rows [J]. cells [1]. innertext;
If (stritemnum2 = itemnum)
{
Document. getelementbyid (zptextid1). value = 0;
}
}
}
}
}
// Cascading scoring
Function felatingsum ()
{
VaR objtable = Document. getelementbyid ("dgrdlist ");
// Divide the parent-level self-evaluation into 0 Points
Setfathernum ();

// Calculate the parent-level self-Score Based on the sub-level self-Score
For (VAR I = objtable. Rows. Length-2; I> 0; I --)
{
VaR stritemnum1 = objtable. Rows [I]. cells [1]. innertext;
VaR arrayitemnum = stritemnum1.split (".");
VaR arraycount = arrayitemnum. length;
If (arraycount> 1)
{
VaR itemnum = "";
For (VAR n = 0; n <= arrayCount-2; n ++)
{
Itemnum + = "." + arrayitemnum [N];
}

Itemnum = itemnum. substring (1, itemnum. Length );

For (var j = objtable. Rows. Length-2; j> 0; j --)
{
VaR idsum1 = parsefloat (j) + parsefloat (1 );
VaR idsum2 = parsefloat (I) + parsefloat (1 );
VaR zptextid1 = "dgrdlist _ CTL" + idsum1 + "_ selfappraisenum ";
VaR zptextid2 = "dgrdlist _ CTL" + idsum2 + "_ selfappraisenum ";

VaR stritemnum2 = objtable. Rows [J]. cells [1]. innertext;
If (stritemnum2 = itemnum)
{
Document. getelementbyid (zptextid1). value = parsefloat (document. getelementbyid (zptextid1). Value) + parsefloat (document. getelementbyid (zptextid2). value );
}
}
}
}
// Total statistics
Statsum ();
}
// Total statistics
Function statsum ()
{
VaR objtable = Document. getelementbyid ("dgrdlist ");
VaR countsum = 0;
VaR standardsum = 0;
// Calculate the parent-level self-Score Based on the sub-level self-Score
For (VAR I = objtable. Rows. Length-2; I> 0; I --)
{
VaR stritemnum1 = objtable. Rows [I]. cells [1]. innertext;
VaR arrayitemnum = stritemnum1.split (".");
VaR arraycount = arrayitemnum. length;
VaR idsum1 = parsefloat (I) + parsefloat (1 );
VaR zptextid1 = "dgrdlist _ CTL" + idsum1 + "_ selfappraisenum ";
If (arraycount = 1)
{
Countsum = parsefloat (countsum) + parsefloat (document. getelementbyid (zptextid1). value );
Standardsum = parsefloat (standardsum) + parsefloat (objtable. Rows [I]. cells [4]. innertext );
}
}
Objtable. Rows [objtable. Rows. Length-1]. cells [6]. innertext = countsum;
Objtable. Rows [objtable. Rows. Length-1]. cells [4]. innertext = standardsum;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.