Advertisement
Guest User

Untitled

a guest
Jun 26th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.03 KB | None | 0 0
  1. <script type="text/javascript">
  2. (function ($) {
  3. $(document).ready(function() {
  4. $('#send_enquiry').click(function(){
  5. $('#contactform').fadeIn(500);
  6. $('html, body').animate({scrollTop: $("#contactform").offset().top-200}, 1000);
  7. });
  8. $('#send_enquiry').on('statechangecomplete', function(){
  9. $('#contactform').fadeIn(500);
  10. });
  11. var hash = window.location.hash;
  12. if(hash == '#contactform'){
  13. $('#contactform').fadeIn(500);
  14. }
  15. $("#user_about").change(function(){
  16. var selectedAbout= $("#user_about option:selected").val();
  17. if(selectedAbout == 'advertising'){
  18. //$("#user_to").val('advertising@fm963.sg');
  19. $("#user_to").val('jayeshmahajan23@gmail.com,jay5mfl@gmail.com');
  20. }else if(selectedAbout == 'marketing'){
  21. $("#user_to").val('marketing@fm963.sg');
  22. }else if(selectedAbout == 'technical'){
  23. $("#user_to").val('technical@fm963.sg');
  24. }
  25. });
  26. $("#contactform").submit(function(e) {
  27. e.preventDefault();
  28. $('.alert-danger').hide(); // remove the error class
  29. var frmid = $("#form_id").val();
  30. var formData = {
  31. 'action': 'sph_contactform_ajax'
  32. };
  33. $('#contactform input,#contactform select,#contactform fieldset,#contactform textarea').each(function(i, v) {
  34. var field_name = $(this).attr('name');
  35. if(field_name != undefined){
  36. formData[field_name] = $(this).val();
  37. }
  38.  
  39. });
  40. $.ajax({
  41. type : "post",
  42. dataType : "json",
  43. url : myAjax.ajaxurl,
  44. data : formData,
  45. success: function (data) {
  46. if (!data.success) {
  47. $('#success_con'+frmid).hide();
  48. $('#error_con_msg'+frmid).html(data.msg);
  49. $('#error_con'+frmid).fadeIn( "slow" );
  50. $('#error_con_msg'+frmid).fadeIn( "slow" );
  51. grecaptcha.reset();
  52. $('html, body').animate({scrollTop: ($(".error_con").offset().top)-300}, 2000);
  53. } else {
  54. $('#error_con'+frmid).hide();
  55. $('#success_con'+frmid).fadeIn( "slow" );
  56. $('#success_con_msg'+frmid).html( data.msg );
  57. $("#contactform")[0].reset();
  58. grecaptcha.reset();
  59. $('html, body').animate({scrollTop: ($(".success_con").offset().top)-300}, 2000);
  60. }
  61. }
  62. }).fail(function(data) {
  63. $('#error_con_msg'+frmid).html('Something wrong, please contact our customer service (1800 69 78701)');
  64. $('#error_con'+frmid).fadeIn( "slow" );
  65. $("#contactform")[0].reset();
  66. grecaptcha.reset();
  67. });
  68. return false;
  69. });
  70.  
  71. });
  72. }(jQuery));
  73.  
  74. /* Code added to scroll page to PDPA, Advertise with us and technical support links */
  75. function GetURLParameter(sParam){
  76. var sPageURL = window.location.search.substring(1);
  77. var sURLVariables = sPageURL.split('&');
  78. for (var i = 0; i < sURLVariables.length; i++){
  79. var sParameterName = sURLVariables[i].split('=');
  80. if (sParameterName[0] == sParam){
  81. return sParameterName[1];
  82. }
  83. }
  84. }
  85. jQuery(document).ready(function(){
  86. var gtparam = GetURLParameter('a');
  87. if(gtparam == 'technical'){
  88. jQuery(".technicaltab").addClass("vc_active");
  89. setTimeout("jQuery('html, body').animate({scrollTop: jQuery('.technicaltab').offset().top-120}, 1000);", 500);
  90. }
  91. if(gtparam == 'pdpa'){
  92. jQuery(".pdpatab").addClass("vc_active");
  93. setTimeout("jQuery('html, body').animate({scrollTop: jQuery('.pdpatab').offset().top-120}, 1000);", 500);
  94. }
  95. if(gtparam == 'advertise'){
  96. jQuery(".advertisetab").addClass("vc_active");
  97. setTimeout("jQuery('html, body').animate({scrollTop: jQuery('.advertisetab').offset().top-120}, 1000);", 500);
  98. }
  99.  
  100. });
  101. </script>
  102.  
  103.  
  104. ------------------------------------------------------------------
  105. [sph_contact_form_shortcode captcha="0" form_id=1 smsapi="" smsapiparam=""]
  106.  
  107. <?php
  108. /**
  109. * Extra form validation
  110. * 1. Add code inside $_POST condition to do after post validation
  111. * 2. Store all error messages in $obj->errors[]
  112. * 3. To change success message store message in $success variable
  113. */
  114.  
  115. if(!empty($_POST)){
  116.  
  117.  
  118. if(!empty($_POST['user_about']) && $_POST['user_about'] == 'advertising'){
  119. //$_POST['user_about'] = 'advertising@fm963.sg';
  120. $_REQUEST['user_to'] = 'sph.schee@gmail.com';
  121. }elseif(!empty($_POST['user_about']) && $_POST['user_about'] == 'marketing'){
  122. //$_POST['user_about'] = 'marketing@fm963.sg';
  123. $_REQUEST['user_to'] = 'sph.schee@gmail.com';
  124. }elseif(!empty($_POST['user_about']) && $_POST['user_about'] == 'technical'){
  125. //$_POST['user_about'] = 'technical@fm963.sg';
  126. $_REQUEST['user_to'] = 'sph.schee@gmail.com';
  127. }
  128.  
  129.  
  130. if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])){
  131. //your site secret key
  132. $secret = '6Lf0vT0UAAAAAPstbDTopFfxSWzpWe1GmE2utPN9';
  133. //get verify response data
  134. $verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$_POST['g-recaptcha-response']);
  135. $responseData = json_decode($verifyResponse);
  136.  
  137. if(!$responseData->success){
  138. $obj->errors[] = 'Prove you are not a robot.';
  139. }
  140. } else {
  141. $obj->errors[] = 'Prove you are not a robot.';
  142. }
  143.  
  144. // 1 is form id which you can get from shortcode : [sph_contact_form_shortcode form_id=1]
  145. $success[1] = "Thank you , we will get back to you so soon!!!";
  146.  
  147. }
  148.  
  149. /**
  150. * Form HTML
  151. * 1. Dont add form tags in form html
  152. * 2. Dont add submit button html in form html
  153. */
  154.  
  155. $form_html = '
  156. <div class="error_con" id="error_con1" style="display:none;">
  157. <div>
  158. <div class="alert alert-danger small" role="alert" id="error_con_msg1" style="display: block;"></div>
  159. </div>
  160. </div>
  161. <div class="success_con" id="success_con1" style="display:none;">
  162. <div>
  163. <div class="alert alert-success small" role="alert" id="success_con_msg1">
  164. </div>
  165. </div>
  166. </div>
  167. <div class="form_container">
  168. <div class="sph_form_div"><label class="sph_form_label NotoSansReg"> First Name </label>
  169. <input class="sph_form_input NotoSansReg" name="user_first_name" type="text"
  170. placeholder="e.g Paul" /></div>
  171. <div class="sph_form_div"><label class="sph_form_label NotoSansReg"> Last Name </label>
  172. <input class="sph_form_input NotoSansReg" name="user_last_name" type="text"
  173. placeholder="e.g Appleseed" /></div>
  174. <div class="sph_form_div"><label class="sph_form_label NotoSansReg"> Email </label>
  175. <input class="sph_form_input NotoSansReg" name="user_email" type="text"
  176. placeholder="e.g paul@email.com" /></div>
  177. <div class="sph_form_div"><label class="sph_form_label NotoSansReg"> Telephone </label>
  178. <input class="sph_form_input NotoSansReg" name="user_telephone" type="text"
  179. placeholder="e.g +65-" /></div>
  180. <div class="sph_form_div"><label class="sph_form_label NotoSansReg"> Mobile Number </label>
  181. <input class="sph_form_input NotoSansReg" name="user_mobile_number" type="text"
  182. placeholder="starts with a \'8\' or \'9\' " /></div>
  183. <div class="sph_form_div"><label class="sph_form_label NotoSansReg"> About</label>
  184. <select name="user_about" class="sph_form_select NotoSansReg" id="user_about">
  185. <option value="">Select</option>
  186. <option value="advertising">Advertising</option>
  187. <option value="marketing">Marketing</option>
  188. <option value="technical">Technical</option>
  189. </select>
  190. <input type="hidden" value="" name="user_to" id="user_to">
  191. </div>
  192. <div class="sph_form_div"><label class="sph_form_label NotoSansReg"> Your questions
  193. or comments </label> <textarea class="sph_form_textarea NotoSansReg"
  194. name="user_questions" placeholder="Write here"></textarea>
  195. </div>
  196. <input type="hidden" name="form_id" id="form_id" value="1" />
  197. <div class="sph_form_div">
  198. <script src=\'https://www.google.com/recaptcha/api.js\'></script>
  199. <div class="sph_radio_captch">
  200. <div class="g-recaptcha" data-sitekey="6Lf0vT0UAAAAAI_0ubf6etkWwobZyi2YvPHANQ-b"></div>
  201. </div>
  202. </div>
  203. </div>
  204. ';
  205.  
  206. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement