		<script>
			jQuery(document).ready(function() {

				var google_formURL = "https://docs.google.com/forms/d/e/1FAIpQLSeWNCarRxP-P03imGM-BpTzbR2I31ctAqgLg5dRazCUvnUAmg/viewform";

				function gotoFormBtnOnChange() {
					if (jQuery("#gac-yes").prop('checked')) {
						jQuery('#question2').hide("slow");
					} else if (jQuery("#gac-no").prop('checked')) {
						jQuery('#question2').show("slow");
					}
				}

				function needPhotoOnChange() {
					if (jQuery("#wp-yes").prop('checked')) {
						jQuery('#upload-photo-div').show("slow");
					} else {
						jQuery('#upload-photo-div').hide("slow");
					}
				}

				function uploadedDetect(form_url) {
					if ('') {
						//Prefill this column
						if ('' == 'null') {
							window.location.href = form_url;
						} else {
							let url = form_url + "?entry.1283531853=" + '';
							window.location.href = url;
						}
					}
				}

				function fileSizeDetection() {
					document.getElementById('frform').addEventListener('submit', (evt) => {
						var file = document.getElementById('photo_upload').files[0];

						if (file && file.size < (20 * 1024 * 1024)) { // Max file size = 20 MB (this size is in bytes)
							//Submit form        
						} else if (file.size > (20 * 1024 * 1024)) {
							alert('你上傳的檔案太大了，請上傳一張小於20MB的圖片!');
							evt.preventDefault();
						}
					}, false);
				}


				function PageonLoad() {
					uploadedDetect(google_formURL);
					jQuery('#question1 input').change(gotoFormBtnOnChange);
					jQuery('#question2 input').change(needPhotoOnChange);
					fileSizeDetection();
				}
				PageonLoad();
			});
		</script>

		<div class="formRedirect">
			<div class="innerDiv">
				<h1>
					歡迎來到扶輪公園的測試網頁。
					<br>
					你完成測驗後，我們將會為你準備一張證書。
					<br>
				</h1>
				<form method="post" action="#" enctype="multipart/form-data" id="frform">

					<div id="question2" class="radiolabel">
						<h2 class="fr-title">請問證書上需要有你的相片嗎？*</h2>
						<br>
						<h3 style="color:darkred;">*若你選擇上傳相片，該相片亦會公開分享至新界扶輪社的網頁上。</h3>
						<label for="wp-yes">
							<input type="radio" id="wp-yes" name="wantPhoto" value="yes">
							<span>需要</span>
						</label>
						<label for="wp-no">
							<input type="radio" id="wp-no" name="wantPhoto" value="no" checked>
							<span>不需要</span>
						</label>
					</div>

					<div id="upload-photo-div" style="display:none;">
						<h2 class="fr-title">請選擇你的證書圖片</h2>
						<label for="photo_upload">
							<input type="file" id="photo_upload" name="photo_upload" multiple="false" accept="image/*">
							<input type="hidden" name="post_id" id="post_id" value="4948" />
						</label>
					</div>
					<button id="submitBtn" type="submit"><span>開始測驗</span></button>

				</form>
			</div>
		</div>

{"id":4948,"date":"2021-06-17T18:42:04","date_gmt":"2021-06-17T10:42:04","guid":{"rendered":"http:\/\/www.rotarynt.org\/RotaryNT\/?page_id=4948"},"modified":"2026-06-02T06:37:32","modified_gmt":"2026-06-01T22:37:32","slug":"form-redirect","status":"publish","type":"page","link":"http:\/\/www.rotarynt.org\/RotaryNT\/form-redirect\/","title":{"rendered":"Form Redirect"},"content":{"rendered":"\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"ngg_post_thumbnail":0,"pmpro_default_level":0},"_links":{"self":[{"href":"http:\/\/www.rotarynt.org\/RotaryNT\/wp-json\/wp\/v2\/pages\/4948"}],"collection":[{"href":"http:\/\/www.rotarynt.org\/RotaryNT\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.rotarynt.org\/RotaryNT\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.rotarynt.org\/RotaryNT\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.rotarynt.org\/RotaryNT\/wp-json\/wp\/v2\/comments?post=4948"}],"version-history":[{"count":2,"href":"http:\/\/www.rotarynt.org\/RotaryNT\/wp-json\/wp\/v2\/pages\/4948\/revisions"}],"predecessor-version":[{"id":4950,"href":"http:\/\/www.rotarynt.org\/RotaryNT\/wp-json\/wp\/v2\/pages\/4948\/revisions\/4950"}],"wp:attachment":[{"href":"http:\/\/www.rotarynt.org\/RotaryNT\/wp-json\/wp\/v2\/media?parent=4948"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}