<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">
  <xi:include href="layout.html" />
  <xi:include href="macros.html" />
<?python
  typename = {1:"単一選択(ラジオボタン)", 2:"単一選択(コンボボックス)", 3:"複数選択(チェックボックス)", 4:"フリー入力(１行)", 5:"フリー入力(複数行)"}
?>

  <head>
    <title>アンケートの明細編集</title>
	<script type="text/javascript">
		function eventHandler(actionName) {
			f = document.forms['question'];
			document.getElementById('actionName').value = actionName;
			if(actionName == "update"){
				f.action = "${href.enquete('editdetail')}";
			} else if(actionName == "cancel"){
				f.action = "${href.enquete('edit')}";
			}
			f.submit();
		}

		function controlField(type){
			if(type=="4" || type=="5"){
				document.getElementById('detail').disabled = 'disabled';
				document.getElementById('detail').value = '';
			} else {
				document.getElementById('detail').disabled = '';
			}
		}
	</script>
  </head>

  <body>
	<form name="question" action="" method="post">
	<div>
		<table width="90%"  class="list">
			<tr>
				<th>設問</th><td><input type="text" name="question_title"  size="70"  value="${question['question_title']}"/></td>
			</tr>
			<tr>
				<th>設問タイプ</th><td><select name="type"  onChange="controlField(this.value);">
					<option py:for="t in [1,2,3,4,5]" value="$t" selected="${t==int(question['type']) or None}">${typename[t]}</option>
				</select>
				</td>
			</tr>
			<tr>
<?python
	disabled=None
	value = question['detail']
	if value == 'None':
		value =''

	if question['type']==4 or question['type']==5:
		disabled='disabled'
?>
				<th>明細</th><td><textarea name="detail" rows="4" cols="80" disabled='${disabled}'>${value}</textarea></td>
			</tr>
			<input type="hidden" name="question_id" value="${question['question_id']}" />
			<input type="hidden" name="enquete_id" value="${enquete_id}" />
		</table>
	</div>
	<div style="padding-left:40px">
		<input type="button" name="update" value="登録"  onclick="eventHandler('update');" />
		<input type="button" name="cancel" value="キャンセル"  onclick="eventHandler('cancel');" />
		<input type="hidden" name="idx"/>
		<input type="hidden" id="actionName"  name="actionName"/>
	</div>
	</form>
  </body>
</html>
