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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
<?php require_once('webadmin/basic_info.php');
$id = (int)$_SESSION["id"]; //check_user_has_fill_form($id); $campaign = get_campaign($id, 1);
if (!isset($_SESSION["id"]) || (int)$_SESSION["id"] <= 0 || empty($campaign)) { missing_campaign_id(); } else { check_campaign_date($campaign); }
$sql = "select * from answer where campaign_id = ? and session_id = ? and temp = ?"; $parameters = array($id, session_id(), 1); $result = bind_pdo($sql, $parameters, "selectone");
if (!empty($result)) { echo "<script type='text/javascript'>alert('You have fill the survey before. Please complete your personal information.\\n你已填妥問卷,請填寫你的個人資料以完成問卷。'); location.href='user_info.php?id=" . $id . "'</script>"; exit; } ?>
<!DOCTYPE html> <html> <head> <?php require_once('html_head.php'); ?> <link rel="stylesheet" type="text/css" media="screen" href="js/form_builder/assets/css/form-builder.min.css">
</head> <body>
<div class="container"> <?php if ($campaign["hide_campaign_name"] == 0) { echo "<h1 style='margin-bottom: 30px;'>"; foreach ($arraylangcode as $langcode => $langname) { if (!empty($campaign["name_" . $langcode])) { echo $campaign["name_" . $langcode] . "<br>"; } } echo "</h1>"; } ?> <div style="<?= $campaign["hide_campaign_name"] == 1 ? "padding-top:30px;" : "" ?>"> <?php foreach ($arraylangcode as $langcode => $langname) { if (!empty($campaign["desc2_" . $langcode])) { echo $campaign["desc2_" . $langcode] . "<br><br>"; } } ?> </div>
<div id="survey_form"> <form action="survey_form_post.php" method="post" name="survey_form" id="survey_form2" enctype="multipart/form-data"> <!-- <span style='padding-left: 0px;'></span> 15px --> <?php echo html_entity_decode(str_replace("||", "<br>", $campaign["form_html"])); ?>
<input type="hidden" name="show_other_error" id="show_other_error" value="0"/> <div class="tc"> <button type="button" class="btn" onclick="check_form();">提交 Submit</button> </div> </form> </div>
</div>
<?php require_once('html_footer.php'); ?>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script type="text/javascript"> $(function () { $("input[type='date']").each(function () { $(this).attr("type", "text"); $(this).attr("placeholder", "MM/DD/YYYY"); });
$(".calendar").datepicker({"dateFormat":"dd/mm/yy"});
$.datepicker.regional['en_tc'] = { closeText: "關閉", prevText: "<上月", nextText: "下月>", currentText: "今天", monthNames: [ "一月 Jan","二月 Feb","三月 Mar","四月 Apr","五月 May","六月 June", "七月 July","八月 Aug","九月 Sept","十月 Oct","十一月 Nov","十二月 Dec" ], monthNamesShort: [ "一月 Jan","二月 Feb","三月 Mar","四月 Apr","五月 May","六月 June", "七月 July","八月 Aug","九月 Sept","十月 Oct","十一月 Nov","十二月 Dec" ], dayNames: [ "星期日","星期一","星期二","星期三","星期四","星期五","星期六" ], dayNamesShort: [ "周日","周一","周二","周三","周四","周五","周六" ], dayNamesMin: [ "日","一","二","三","四","五","六" ], weekHeader: "周", dateFormat: "yy/mm/dd", firstDay: 1, isRTL: false, showMonthAfterYear: true, yearSuffix: "年" };
$.datepicker.setDefaults($.datepicker.regional['en_tc']);
}); </script>
<script type="text/javascript"> /*$(function () { $("#survey_form label").each(function () { var label_space = $(this).html(); label_space = label_space.replace(/ /g, " "); $(this).html(label_space); }); });*/
$(function () { /*$(".checkbox-group .other-option, .radio-group .other-option").each(function () { if ($(this).prop("checked")) { $(this).parent().find("input[type='text']").show(); } else { $(this).parent().find("input[type='text']").hide(); } });
$(".checkbox-group .other-option, .radio-group .other-option").on("click", function () { if ($(this).prop("checked")) { $(this).parent().find("input[type='text']").show(); } else { $(this).parent().find("input[type='text']").hide(); } });*/
$("input[type='text']").on("change", function () { if ($(this).attr('data-other-id') !== undefined && $(this).parent().find(".other-option").prop("checked")) { // attribute is present $(this).parent().find(".other-option").val($(this).val()); } });
$(".other-option").on("click", function () { if ($(this).prop("checked")) { var other_val = $("#" + this.id + "-value").val(); $(this).val(other_val); } else { $(this).val(""); } });
$("input[type='text']").each(function () { if ($(this).attr('data-other-id') !== undefined) { $(this).show(); } });
$(".other-option").each(function () {
if ($(this).prop("checked")) { var other_val = $("#" + this.id + "-value").val(); $(this).val(other_val); } else { $(this).val(""); }
var other_label_for = this.id; var other_label_text = "<?=($campaign["default_language"] == "en" ? "Other" : ($campaign["default_language"] == "tc" ? "其他" : "Other / 其他"))?>";
$("label[for='" + other_label_for + "']").text(other_label_text); }); });
function check_form() { var valid = true; $(".other-option").each(function () {
if ($(this).prop("checked") && !$("#" + this.id + "-value").val()) { valid = false; //alert("Please enter Other.\n請輸入其他.\n\n"); }
});
if (!valid) { $("#show_other_error").val("1"); } else { $("#show_other_error").val("0"); }
$("#survey_form2").submit(); }
</script>
</body> </html>
|