Advertisement
rijarob

Add text field to form upon selection of "Other" from Drop

Jun 9th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. <!-- Add this section to your TEMPLATES configuration settings under "custom checkout fields" -->
  2.  
  3. {% if add_other is not defined %}
  4. {% set add_other = false %}
  5. {% endif %}
  6.  
  7. <div class="fc-form-group ">
  8. <div class="col-sm-8 col-sm-offset-3" data-fc-error-for="referral_source" data-fc-error-class="fc-alert-container--error">
  9. <div class="fc-input-group-container fc-input-group-container--checkbox fc-input-group-container--active">
  10. <label class="fc-input-group-container__title fc-input-group-container__title--forced fc-form-label">
  11. How did you find Us?… (required)
  12. </label>
  13. <div class="fc-form-group">
  14. <p>Referred by?</p>
  15. <select name="referral_source" id="referral_source" class="fc-form-control" aria-required="true" data-fc-required >
  16. <option value="Google" {% if referral_source == "Google" %}selected{% endif %}>Google</option>
  17. <option value="Yahoo" {% if referral_source == "Yahoo" %}selected{% endif %}>Yahoo</option>
  18. <option value="Bing" {% if referral_source == "Bing" %}selected{% endif %}>Bing</option>
  19. <option value="Facebook" {% if referral_source == "Facebook" %}selected{% endif %}>Facebook</option>
  20. <option value="Instagram" {% if referral_source == " Instagram " %}selected{% endif %}> Instagram </option>
  21. <option value="Twitter" {% if referral_source == " Twitter" %}selected{% endif %}> Twitter</option>
  22. <option value="Friend" {% if referral_source == "Friend" %}selected{% endif %}>Friend</option>
  23. <option value="Amazon" {% if referral_source == "Amazon" %}selected{% endif %}>Amazon</option>
  24. <option value="Email" {% if referral_source == "Email" %}selected{% endif %}>Email</option>
  25. <option value="Returning Customer" {% if referral_source == "Returning Customer" %}selected{% endif %}>Returning Customer</option>
  26. <option value="Other" {% if referral_source == "Other" %}selected{% endif %}>Other</option>
  27. </select>
  28. </div>
  29. {% if add_other == true %}
  30. <div class="fc-form-group">
  31. <input type="text"
  32. id="other_text"
  33. name="other_text"
  34. placeholder="Please enter 'Other'"
  35. class="fc-form-control fc-form-control--new-customer-password"
  36. data-fc-required
  37. value="{{ other_text }}"
  38. />
  39. </div>
  40. {% endif %}
  41. </div>
  42. </div>
  43. </div>
  44.  
  45.  
  46. <!-- Add this into your TEMPLATES configuration in "Add custom header and footer code to your templates->custom footer" -->
  47. <!-- Do not overwrite code that is already there -->
  48.  
  49. {% if context == "checkout" %}
  50. <script>
  51. $("body").on("change", "#referral_source",
  52. function() {
  53. var change_to = $( "select#referral_source" ).val();
  54. if (change_to == "Other") {
  55. FC.json.add_other = true;
  56. }
  57. else {
  58. FC.json.add_other = false;
  59. }
  60. FC.checkout.renderAdditionalFields();
  61. $("#referral_source").val(change_to);
  62. });
  63. </script>
  64. {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement