如何根据实体表格中给出的答案评分

时间:2013-09-04 15:48:17

标签: javascript dynamics-crm-2011

我有一个表格,上面有一些问题。每个问题都有选项,每个选项都附有一些要点。在回答完所有问题后,用户应该看到总分 在文本框中。答案将在下拉菜单中。

有什么方法可以为每个答案添加特定的重量吗?顺便说一句,取决于答案,分数可能被加入或减去(负评分)。

我实际上在做的是将选项设置值设置为所需的数字并添加它们以获得结果。但是当两个或更多选项具有相同的权重/分数并且有两个带有负标记的选项时,我遇到了麻烦。所以现在我期待更好的方法来处理这个问题。这是一段代码片段。

function getValue()
{
var optionset = Xrm.Page.getAttribute("inmate_housingq1");

var value = optionset.getValue();

alert(value);

var optionset2 = Xrm.Page.getAttribute("inmate_housingq2");

var value2 = optionset2.getValue();

alert(value2);

var value3 = value + value2; 

alert(value3);

Xrm.Page.getAttribute(“inmate_housing_score“).setValue(“value3”);

}

1 个答案:

答案 0 :(得分:0)

我修改了我的代码。我正在使用选项集的每个选项的ID值,并将所需的标记设置为其ID。这是我最后的工作代码。

function getValue()
{
var optionset = Xrm.Page.getAttribute("inmate_housingq1");
var value = optionset.getValue();
if(value==11)
{
value = value-1; 

}
else
{
value; 
}

var optionset2 = Xrm.Page.getAttribute("inmate_housingq2");
var value2 = optionset2.getValue();
if(value2==11)
{

value2 = value2-1; 

}
else
{
value2; 
}

var optionset3 = Xrm.Page.getAttribute("inmate_housingq3");
var value3=optionset3.getValue();

var optionset4 = Xrm.Page.getAttribute("inmate_housingq4");
var value4=optionset4.getValue();

var optionset5 = Xrm.Page.getAttribute("inmate_housingq5");
var value5=optionset5.getValue();

var optionset6 = Xrm.Page.getAttribute("inmate_housingq6");
var value6=optionset6.getValue();

if(value6==2)
{

value6 = value6-4; 

}
else
{
value6; 
}


var optionset7 = Xrm.Page.getAttribute("inmate_housingq7");
var value7=optionset7.getValue();
if(value7==1)
{
value7 = value7-2;
}
else
{
value7;
}




var optionset8 = Xrm.Page.getAttribute("inmate_housingq8");
var value8=optionset8.getValue();
if(value8==1)
{
value8 = value8-2;
}
else
{
value8;
}

var result = value + value2 + value3 + value4 + value5 + value6 + value7 + value8; 

Xrm.Page.getAttribute("inmate_housing_score1").setValue(result);

}