1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
<?php import_request_variables('pG', 'p_'); $sel_q = "select * from cms_question where id_question = '$p_question_id'"; $que_q = mysql_query($sel_q); $obj_q = mysql_fetch_assoc($que_q);
$navig['question&id_sub='.$p_id_sub] = $p_sub_name; $navig['question_title'] = 'เพิ่มหัวข้อ'; navigator($navig); echo"<br>"; bar_header($p_title); // Bar_Header fieldset_top($obj_q['topic']);
//debuga($_POST);
foreach($_POST as $key => $value){ if(strpos($key, 'choice_no_') > -1){ $arr = explode('_', $key); $no = $arr[2]; $arr_choice[$no] = $value; } } ?> <table width="97%" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td> <center> <FORM NAME='formupdate' METHOD=POST ACTION='index.php?mod=question_output&path=question' onSubmit='return check()'> <input type="hidden" name="id_sub" value="<?php echo $p_id_sub; ?>" /> <input type="hidden" name="sub_name" value="<?php echo $p_sub_name; ?>" /> <input type="hidden" name="question_id" value="<?php echo $p_question_id; ?>" /> <input type="hidden" name="title" value="<?php echo $p_title; ?>" /> <input type="hidden" name="question_type" value="<?php echo $p_question_type; ?>" /> <?php if($p_question_type == '6'){ ?> <table width='98%' border='0' cellpadding='0' cellspacing='0'> <?php text_editor('100%', '260', 'คำอธิบาย', 1, '', 'data_1'); ?> </table> <?php }else{ ?> <?php if(isset($arr_choice)){ ?> <input type="hidden" name="all_choice" value="<?php echo implode('#@+=', $arr_choice); ?>" /> <?php } ?> <table width='98%' border='0' cellpadding='0' cellspacing='1' bgcolor='#eff3f7' id="tb_title"> <tr id="tr_data_1"> <td width='20%' height='30' bgcolor='ffffff'> <img src='coremain/images/marker.gif'> หัวข้อที่ 1</td> <td width='80%' height='30' bgcolor='ffffff'><INPUT TYPE='text' NAME='data_1' size="50" value=''></td> </tr> </table> <?php } ?> <table width="100%" id="bt_question_title"> <?php if($p_question_type != '6'){ ?> <tr> <td align="left"> <button type="button" id="add_data" class="ui-button ui-corner-all ui-state-focus" style="padding: 2px;"> <img src='coremain/images/bullet2.gif'> เพิ่มหัวข้อ</button> <?php if($p_question_type == '3' || $p_question_type == '4'){ ?> <input type="checkbox" name="add_other" value="1" checked="checked" /> มีหัวข้ออื่นๆ <?php } ?> </td> </tr> <?php } ?> <tr> <td align="center"> <?php button_text('เพิ่มแบบสำรวจ', 'Submit', 2); ?> </td> </tr> </table> </FORM> </center> </td> </tr> </table>
<script language="javascript"> $('input[name="data_1"]').focus(); $('#add_data').on('click', function(){ var row = $('#tb_title').find('tr').last().attr('id'); var id = row.split('_'); var n = Number(id[2]) + 1; var tr = '<tr id="tr_data_'+ n +'"><td height="30" bgcolor="ffffff"> <img src="coremain/images/marker.gif"> หัวข้อที่ '+ n +'</td><td height="30" bgcolor="ffffff"><INPUT TYPE="text" NAME="data_'+ n +'" size="50" /> <a href="javascript:void(0);" class="del_data" id="'+ n +'"><img SRC="coremain/images/del1.gif" border="0" title="ลบข้อมูล"></a></td></tr>'; $('#tb_title').append(tr); $('input[name="data_'+ n +'"]').focus(); $('.del_data').on('click', function(){ if(del_data()){ var val = $(this).attr('id'); $('tr#tr_data_'+ val).remove(); } }); }); function check() { if(document.formupdate.topic.value=="") { alert("กรุณากรอกหัวข้อ !") ; document.formupdate.topic.focus() ; return false ; }else if(document.formupdate.question_type.value=='2'){ var chk_text = true; $.each($('.choice_no'), function(){ chk_text &= $(this).val() == '' ? false : true; }); if(!chk_text){ alert('กรุณากรอกคำตอบให้ครบทุกช่อง !'); return false; } }else{ return true ; } } function del_data(){ if(confirm('คุณต้องการลบหัวข้อนี้ ?')){ return true; }else{ return false; } } </script>
|