Jump to content

Ian_A

Circle Member
  • Posts

    8
  • Joined

  • Last visited

Reputation Activity

  1. Like
    Ian_A got a reaction from tuanphan in How to use filename as a title for images in Gallery Block in 7.1 in 2022 ? Please and thank you.   
    Old topic, but incase anyone is still in need of a solution, here is how I do it with jQuery.
    I apply the code per page as I only use it on specific gallery pages made for client previews.
     
    <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
    <script>
        // Function to replace image-slide-title content with alt tag for images within sqs-gallery-container using jQuery
        $(document).ready(function() {
          $('.sqs-gallery-container img').each(function(index) {
            $('.image-slide-title').eq(index).html($(this).attr('alt').replace('.jpg', ''));
          });
        });
      </script> 
  2. Like
    Ian_A reacted to joshbespoke in Form Submission, Unique Subject   
    Thanks @paul2009. I will look into this and give it a try. 
    Would this in turn essentially negate the need for the code injection discussed above do you think? I havent used Zapier as yet so unsure as to its functionality.
    ___
    FYI, and future thread readers. Overnight, I did find the alternate code to change the 'timecode' portion from the random generated number to now display the literal date and time to the second of the form submission. (if it was to be a preference of anyone). (Please note I am in Australia so the code is written to display DD/MM/YYYY, a simple change of the ('en-AU' to display ('en-US' should alter this for you if required).
    This is the new code including the input noted by @creedon as I required this for the function to begin working.
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script>
    $(document).ready(function(){ 
        var timecode = new Date().toLocaleString('en-AU', { day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit' });
        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>
  3. Like
    Ian_A reacted to paul2009 in Form Submission, Unique Subject   
    Although this isn't a built-in feature, you can achieve this by setting your form to use Zapier in Storage Options. You can then use Zapier to add a value that increments with each submission, and email it to you.
    Did this help? Please give feedback by clicking an icon below  ⬇️
  4. Like
    Ian_A got a reaction from joshbespoke in Form Submission, Unique Subject   
    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>
  5. Thanks
    Ian_A reacted to creedon in Form Submission, Unique Subject   
    The $ not defined usually means jQuery is not installed.
    Add the following to Settings > Advanced > Code Injection > HEADER.
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script> Let us know how it goes.
  6. Like
    Ian_A got a reaction from paul2009 in Form Submission, Unique Subject   
    @paul2009 Is correct. I thought the original subject field was different than the one you can add for some reason, but I went and tested mine and it worked just find with a new text field with a label of 'Subject'.
×
×
  • 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.