Jump to content

Peeper

Member
  • Posts

    1
  • Joined

  • Last visited

Posts posted by Peeper

  1. On 8/16/2021 at 1:49 PM, Ian_A said:

    I use a similar method as Mochi, but I use Javascript to autofill the Subject field with a Unix Timestamp giving me a unique number at the end of each subject, then I set the CSS value of the form  Subject field and it's Label to none, making it invisible to the user. The Subject field has to be the first field of the form for this to work, as it has no defining attributes, so this simply modifies the 1st field. Seems to be working so far.

    PAGE HEADER CODE INJECTION

    <script>
    $(document).ready(function(){ 
        var timecode = Date.now();
        var subjecttxt = "#" + timecode;
      
      $('form').find("input[type=text], text").each(function()
      {
          if(!$(this).val()) { 
         $(this).attr("value", subjecttxt);
         $(this).attr("readonly", true);
         $(this).css("display","none");
            var val = subjecttxt;
            return ( val !== subjecttxt );
      }
      });
    });

      $(document).ready(function(){ 
    $('form').find("label[class=title]").each(function()
      {
          if(!$(this).val()) { 
         $(this).css("display","none");
            var val2 = "none";
            return ( val2 !== "none" );
      }
      });
    });  
     </script>

    How would I get this to work if I have multiple forms on my website? Would there be a way for each form to have a unique subject line? 

    Thank you so much for the help!

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.