Survey是很实用的WSS组件,可以用来做调查,在线测试.
近日在浏览SharePoint Forums时,看到有人问怎么给Finish按钮增加javascript功能,
一开始回复了思想和方法,建议他改变Form参数Action中的Source部分,
后来自己试了试,因为对JavaScript已经生疏,忘记了Function怎么转换为String和String怎么转换为Function,没有成功,今天了解了下Function,于是完善代码,并测试通过.
与大家共享:
<script type="text/javascript">
var inputcCtrls = document.body.getElementsByTagName("input");
for(m=0; m<inputcCtrls.length; m++) {
if(inputcCtrls[m].type=="button"&&inputcCtrls[m].value=="Finish")
{
var funcHack= inputcCtrls[m].onclick;
var strHack = String(funcHack);
var startParenth = strHack.indexOf('{');
strHack = strHack.substring(startParenth+1);
var endParenth = strHack.indexOf('}');
strHack = strHack.substring(0, endParenth-1);
strHack = " if(confirm('Want to create a new response?')) { document.forms[0].action = 'NewForm.aspx?Source=http%3a%2f%2fservername%2fLists%2fSurveyName%2fNewForm.aspx'; } else { document.forms[0].action = 'NewForm.aspx?Source=http%3a%2f%2fservername%2fLists%SurveyName%2foverview.aspx'; } " + strHack;
var modifyFinishBehavior = new Function(strHack);
inputcCtrls[m].onclick = modifyFinishBehavior;
}
}
</script>
使用方法: 把js代码复制粘帖到NewForm.aspx中.