<html>
<head>
<meta http-equiv=content-language content=zh-cn>
<meta http-equiv=content-type content="text/html; charset=gb2312">
<style>
 td {padding:2px 0px 2px 0px;}
 .classtd { padding:2px 5px 2px 5px;}
</style>
<link href="../CSS/Base.css" rel=stylesheet>
<LINK href="../CSS/Window.css" type=text/css rel=stylesheet>
<script type="text/javascript" src="../JS/Common.js.php"></script>
<script type="text/javascript" src="../JS/Window.js.php"></script>
<script language=javascript src="../JS/Textarea.js.php"></script>
<script language=javascript src="../JS/HighLight.js.php"></script>
<script language=javascript src="../JS/CheckQuestion.js.php"></script>
<script type="text/javascript" src="../JS/TableRows.js.php"></script>
<script language=javascript>
var editTextRange;
function Check_Form_Validator()
{
	if (!CheckNotNull(Check_Form.questionName, "题目文字")) {return false;}
	if ( Trim(document.Check_Form.elements[2].value) == "" ) 
	{
		 alert('请至少选择输入一个问题选项!');
		 document.Check_Form.elements[2].focus();
		 return false;
	}
	var theLength = document.getElementById('theOptionTable').rows.length;
	if ( document.Check_Form.isRequired0.checked)
	{
		if (!CheckNumber(Check_Form.minQtnOption, "最少选项数",1,100)) {return false;}
		//开始计算不是互斥项的数目
		var theNotIsExclusiveNum = 0;
		for( k=0;k<theLength;k++)
		{
			var u = k+1;
			var theIsExclusive = eval("document.getElementById(\"isExclusive_" + u + "\")");
			var theOptionID = eval("document.getElementById(\"optionID_" + u + "\")");
			if( (theIsExclusive != null && ! theIsExclusive.checked) && (theOptionID != null && Trim(theOptionID.value) != '') )
			{
			   theNotIsExclusiveNum++;
			}
		}
		if ( Check_Form.minQtnOption.value != '' && ( theNotIsExclusiveNum <= Number(Check_Form.minQtnOption.value) ) )
		{
			alert('互斥选项太多，不是互斥项的数目总和必须大于最少选项数');
			Check_Form.minQtnOption.focus();
			return false;
		}		
		if (!CheckNumber(Check_Form.maxQtnOption, "最多选项数",2,1000)) {return false;}
		if ( Check_Form.maxQtnOption.value != '' )
		{
			if (Check_Form.minQtnOption.value != '' && ( Number(Check_Form.maxQtnOption.value ) < Number(Check_Form.minQtnOption.value) ) )
			{
				alert('最多选项数必须大于最少选项数');
				Check_Form.maxQtnOption.focus();
				return false;
			}
		}

	}
	for( i=0;i<theLength;i++)
	{
		var j = i+1;
		var theOptionID = eval("document.getElementById('optionID_" + j +"')");
		var theOptionSize = eval("document.getElementById('optionSize_" + j +"')");
		var theIsCheckType = eval("document.Check_Form.isCheckType_" + j +"");
		var theMinOption = eval("document.getElementById(\"minOption_" + j + "\")");
		var theMaxOption = eval("document.getElementById(\"maxOption_" + j + "\")");
		var theIsHaveText = eval("document.getElementById(\"isHaveText_" + j + "\")");
        if( theOptionID != null )
		{
			if( Trim(theOptionID.value) != "" && theIsHaveText.checked )
			{
				if (!CheckNotNull(theOptionSize, "文本输入框长度")) {return false;}
				if (!CheckNumber(theOptionSize, "文本输入框长度",2,80)) {return false;}
			}

			switch( theIsCheckType.value )
			{
			   case '0':
			   case '1':
			   case '3':
			   case '5':
			   case '6':
			   case '7':
			   case '8':
			   case '9':
			   case '10':
			   break;
			   case '2':
			   case '4':
					if (!CheckNotNull(theMinOption, "要求的输入最少值")) {return false;}
					if (!CheckNotNull(theMaxOption, "要求的输入最多值")) {return false;}
					if (!CheckMinMaxNum(theMinOption, "要求的输入最少值")) {return false;}
					if (!CheckMinMaxNum(theMaxOption, "要求的输入最多值")) {return false;}
					if (Number( theMaxOption.value ) < Number(theMinOption.value) )
					{
						alert('区间值的最多值必须大于最少值');
						theMaxOption.focus();
						return false;
					}
			   break;
			}
		}
	}
}
function checkIsCheckType(value,optionOrderID)
{
   var theMinOption = eval("document.getElementById(\"minOption_" + optionOrderID + "\")");
   var theMaxOption = eval("document.getElementById(\"maxOption_" + optionOrderID + "\")");
   var theCheckInfo = eval("document.getElementById(\"checkInfo_" + optionOrderID + "\")");
   switch( value )
   {
		case '0':
		case '1':
		case '3':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
		case '10':
		   theMinOption.disabled  = true
		   theMaxOption.disabled  = true
		   theCheckInfo.innerHTML= '';
		break;
		case '2':
		   theMinOption.disabled  = false
		   theMaxOption.disabled  = false
		   theCheckInfo.innerHTML= '';
		break;
		case '4':
		   theMinOption.disabled  = false
		   theMaxOption.disabled  = false
		   theCheckInfo.innerHTML= '';
		break;
   }
}
//检查输入内容是否为数字
function CheckMinMaxNum(objField, strText) {
  if (objField.value == "") return true;
  var RE = new RegExp("[^0-9]");
  if (objField.value.search(RE) != -1) {
    alert("“" + strText + "”中只能填写整数！");
    objField.focus();
    return false;
  }
  return true;
}

function checkIsHaveText(optionOrderID)
{
   var theOptionSize = eval("document.getElementById(\"optionSize_" + optionOrderID + "\")");
   var theIsRequired = eval("document.getElementById(\"isRequired_" + optionOrderID + "\")");
   var theIsCheckType = eval("document.getElementById(\"isCheckType_" + optionOrderID + "\")");
   var theMinOption = eval("document.getElementById(\"minOption_" + optionOrderID + "\")");
   var theMaxOption = eval("document.getElementById(\"maxOption_" + optionOrderID + "\")");
   var theCheckInfo = eval("document.getElementById(\"checkInfo_" + optionOrderID + "\")");
   var theIsHaveText = eval("document.getElementById(\"isHaveText_" + optionOrderID + "\")");
   if( theIsHaveText.checked)
   {
      theOptionSize.disabled = false;
      theIsRequired.disabled = false;
      theIsCheckType.disabled = false;
      theMinOption.disabled = false;
      theMaxOption.disabled = false;
	  return 1;
   }
   else
   {
      theOptionSize.disabled = true;
      theIsRequired.disabled = true;
      theIsCheckType.disabled = true;
      theMinOption.disabled = true;
      theMaxOption.disabled = true;
	  return 0;
   }
}
function checkIsRequired()
{
   if (document.Check_Form.isRequired0.checked)
   {
		document.Check_Form.minQtnOption.disabled  = false
		document.Check_Form.maxQtnOption.disabled  = false
   } 
   else
   {
		document.Check_Form.minQtnOption.disabled  = true
		document.Check_Form.maxQtnOption.disabled  = true
   }	
}

function Init()
{
	checkIsRequired();
	var theLength = document.getElementById('theOptionTable').rows.length;
	var theIsCheckType = eval("document.getElementById(\"isCheckType_" + 1 + "\")");
	for( i=0;i<theLength;i++)
	{
		var m = i+1;
		var theIsHaveText = eval("document.getElementById(\"isHaveText_" + m + "\")");
		if( theIsHaveText != null && checkIsHaveText(m) )
		{
			var theIsCheckType = eval("document.getElementById(\"isCheckType_" + m + "\")");
			checkIsCheckType(getSelectValue(theIsCheckType),m);
		}
	}
}
function getSelectValue(objField)
{
	if( objField != null ) {
		for( k=0;k<objField.options.length;k++ ) 
		{   
			if(objField.options[k].selected)
			{
				return objField.options[k].value;
			}
		}
	}
}
</script>

<meta content="mshtml 6.00.3790.0" name=generator></head>
<body oncontextmenu="return false" onload="javascript:Init();" style="margin-top:0px">
  <table class=datatable style="line-height: 150%;border-collapse:collapse;" cellspacing=0 cellpadding=0 bordercolor=#b5cfd9 border=1 width=100%>
   <div class=position>位置：&nbsp; 我的问卷 &raquo; 编辑问卷问题 &raquo; 复合多选题</div>
   <tr><td colspan="2" bgcolor="#e9e9e9" class=classtd><b>编辑问卷问题</b></td></tr>
   <form method="post" action="" name="Check_Form" onsubmit="return Check_Form_Validator()">
   <tr><td class=classtd>
     <span style="float:left">&nbsp;<span style="font-size:14px;font-weight:bold;">复合多选题</span>&nbsp;
     <a onmouseover="this.T_WIDTH=446;this.T_PADDING=0;this.T_BGCOLOR='#ffffff'; return escape('<img src=../Images/Example/example_combcheckbox.jpg width=446 align=center>')" href="javascript:void(0);"><font color=red>图例</font></a></span>
	 <span style="float:right"><A href="{thisURLStr}&Actiones=ChangeQtnType&questionID={questionID}&questionName={question_Name}&objType=3"><font color=red><b>置换成“多选题”</b></font></a>&nbsp;</span>	 
   </td></tr>
   <tr bgcolor="#f5f5f5" height=25><td class=classtd><b>&nbsp;关于...</b>&nbsp;<img src="../Images/info.gif" border=0></td></tr>   <tr><td class=classtd>&nbsp;复合多选题是普通多选题的一种扩展，指每个问题选项后可带文本填空的特殊多选题。</td></tr>
   <tr bgcolor="#f5f5f5" height=25><td class=classtd><b>&nbsp;题目文字</b>&nbsp;<img src="../Images/info.gif" border=0>
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" onclick="javascript:{var textEditor = document.getElementById('questionName');textEditor.focus();editTextRange = textEditor.document.selection.createRange();showPopWin('ShowInsertImage.php', 590, 260, null, null,'插入图片或视频');}"><font color=red><b>插入图片或视频</font></b></a><img src="../Images/list_menu_arrow.gif" border=0>
   </td></tr>
   <tr><td class=classtd><textarea rows=5 cols=128 name="questionName" id="questionName" tabIndex=1>{questionName}</textarea>  <a href="javascript:resizeTextHeight('questionName',1);"><img src="../Images/jia.gif"></a><a href="javascript:resizeTextHeight('questionName',-1);"><img src="../Images/jian.gif"></a></td></tr>
   <tr bgcolor="#f5f5f5" height=25><td class=classtd>&nbsp;有关问题的说明或问题回复提示&nbsp;<img src="../Images/info.gif" border=0></td></tr>
   <tr><td class=classtd><textarea rows=3 cols=128 name="questionNotes" id="questionNotes" tabIndex=1>{questionNotes}</textarea>  <a href="javascript:resizeTextHeight('questionNotes',1);"><img src="../Images/jia.gif"></a><a href="javascript:resizeTextHeight('questionNotes',-1);"><img src="../Images/jian.gif"></a></td></tr>
   <tr bgcolor="#f5f5f5" height=25><td class=classtd><b>&nbsp;问题选项</b>&nbsp;<img src="../Images/info.gif" border=0></td></tr>
   <tr><td class=classtd>
    <table id="theOptionTable" style="LINE-HEIGHT: 150%;border-collapse:collapse;" cellSpacing=0 cellPadding=0 width="100%" borderColor=#999999 border=1 style="margin:0px;padding:0px">
	 <tr bgcolor="#cccccc">
	     <td width=3% nowrap>&nbsp;<a href="javascript:void(0)" onclick="insertCombCheckBoxRow(document.getElementById('theOptionTable').rows.length)" title="增加选项"><img src="../Images/jia.gif" border=0></a>&nbsp;<a href="javascript:void(0)" onclick="deleteCombCheckBoxRow()" title="减少选项"><img src="../Images/jian.gif" border=0></a></td>
	     <td width=25%>&nbsp;<b>选项</b>&nbsp;&nbsp;<a href="javascript:void(0)" onclick="javascript:showPopWin('ShowBatchOption.php?isRange=3', 570, 290, null, null,'批量增加选项');"><font color=red><b>批量增加选项</font></b></a></td>
		 <td width=5%><b>互斥</b></td>
		 <td width=7%><b>文本框</b></td>
		 <td width=5%><b>长度</b></td>
		 <td width=5%><b>必答</b></td>
		 <td width=49%>&nbsp;<b>文本框输入检查规则</td></tr>
	 <!-- BEGIN OPTION -->
	 <tr><td align=center>&nbsp;{optionOrderID}：</td>
	     <td>&nbsp;<input size=30 name="optionID[{optionOrderID}]" id="optionID_{optionOrderID}" value="{optionName}">&nbsp;</td>
		 <td>&nbsp;<input type="checkbox" value="1" name="isExclusive[{optionOrderID}]" id="isExclusive_{optionOrderID}" {isExclusive}></td>
		 <td align=center>&nbsp;<input type="checkbox" value="1" name="isHaveText[{optionOrderID}]" id="isHaveText_{optionOrderID}" {isHaveText} onclick="checkIsHaveText({optionOrderID});">&nbsp;</td>
		 <td>&nbsp;<input size=2 name="optionSize[{optionOrderID}]" id="optionSize_{optionOrderID}" value="{optionSize}"></td>
		 <td>&nbsp;<input type="checkbox" value="1" name="isRequired[{optionOrderID}]" id="isRequired_{optionOrderID}" {isRequired}></td>
		 <td>&nbsp;<select name="isCheckType_{optionOrderID}" id="isCheckType_{optionOrderID}" onchange="checkIsCheckType(document.Check_Form.isCheckType_{optionOrderID}.options[document.Check_Form.isCheckType_{optionOrderID}.selectedIndex].value,{optionOrderID});">
		     <option value="0" {isCheckType0_{optionOrderID}}>请选择输入检查规则</option>
		     <option value="1" {isCheckType1_{optionOrderID}}>检查输入为Email</option>
		     <option value="2" {isCheckType2_{optionOrderID}}>检查字符串长度</option>
		     <option value="3" {isCheckType3_{optionOrderID}}>禁止字符串出现中文</option>
		     <option value="4" {isCheckType4_{optionOrderID}}>检查输入为数值</option>
		     <option value="5" {isCheckType5_{optionOrderID}}>检查输入为电话号码</option>
		     <option value="6" {isCheckType6_{optionOrderID}}>检查输入为日期</option>
		     <option value="7" {isCheckType7_{optionOrderID}}>检查输入为身份证号</option>
		     <option value="8" {isCheckType8_{optionOrderID}}>检查输入为企业法人代码</option>
		     <option value="9" {isCheckType9_{optionOrderID}}>检查输入为邮政编码</option>
		     <option value="10" {isCheckType10_{optionOrderID}}>检查输入为网址</option>
		    </select>&nbsp;&nbsp;<span id=checkInfo_{optionOrderID}>区间值：</span>最少：<input name="minOption[{optionOrderID}]" id="minOption_{optionOrderID}" type="text" size=4 value="{minOption}">&nbsp;最多：<input name="maxOption[{optionOrderID}]" type="text" size=4  id="maxOption_{optionOrderID}"  value="{maxOption}"></td>
	 </tr>
	 <!-- END OPTION -->
     </table></td>
   </tr>
   <tr bgcolor="#f5f5f5" height=25><td class=classtd><b>&nbsp;显示设置</b>&nbsp;<img src="../Images/info.gif" border=0></td></tr>
   <tr><td class=classtd>
	    &nbsp;&nbsp;<input type="checkbox" value="1" name="isRandOptions" {isRandOptions}> 选项随机排列 <br/>
   </td></tr>
   <tr bgcolor="#f5f5f5" height=25><td class=classtd><b>&nbsp;控制设置</b>&nbsp;<img src="../Images/info.gif" border=0></td></tr>
   <tr><td class=classtd>
	    &nbsp;&nbsp;<input type="checkbox" value="1" name="isRequired0" {isRequired0} onclick="checkIsRequired();"> 此题为必答题 <br/>
	    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;最少选项数 <input type="text" value="{minOption0}" name="minQtnOption" size=6> <br/>
	    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;最多选项数 <input type="text" value="{maxOption0}" name="maxQtnOption" size=6> <br/>
   </td>
   </tr></table><table width=100%>
   <tr> 
  	 <td height="15" class=classtd>
         <input name="surveyID" type="hidden" id="surveyID" value="{surveyID}"> 
         <input name="questionID" type="hidden" id="questionID" value="{questionID}"> 
         <input name="orderByID" type="hidden" id="orderByID" value="{orderByID}"> 
         <input class=inputsubmit name="AddCombCheckBoxSubmit" type=submit id="AddCombCheckBoxSubmit" value="保存，下一个"> 
         <input class=inputsubmit name="AddCombCheckBoxOver" type=submit id="AddCombCheckBoxOver" value="保存，结束"> 
         <input class=inputsubmit type="button" name="close" value="  关闭  " onClick="javascript:parent.hidePopWin();">
      </td>
    </tr>
  </form>
 </table>
  <script type="text/javascript">initInputHighlightScript();</script> 
  <script language=javascript src="../JS/Example.js.php"></script>
</body></html>
