Jump to content

carlJS

Members
  • Content Count

    16
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by carlJS

  1. Hello @Empowering,

     

    It might be because your field [@field:Opportunity_Name] contains a literal & value. This usually happens when you submit on a Rich Tex Editor.

     Try checking your DataSheet if this is the case. If it is, you may need to run the function over to some HTML Entity decoder like this one [link].


    You may also try checking this solution. Which, I think, the output will be the same. If it is, then it is likely that my assumption above is true.

     

  2. Hello @NickO,

     

    I must've misunderstood your OP in my previous comment.
     

    Now, I assume what you are trying to do is to specify an onload value to an inline edit fields that is a Cascading Dropdown of multiple levels (Cascading Field on a Cascading Field).


    If my assumption is correct, then that's great. I've been trying to work on a solution for it and it's harder than it seems since Caspio is using a custom DropBox picker.

     

    Below is a prototype. It works intermittently. Make sure that the first item in the elements array is the parent field. Also, this codes assume that the Parent Field is a "Dropdown". Again, as mentioned, this is a WIP.

    <script>
    
    var ev_md = new Event("mousedown");
    
    document.addEventListener('DataPageReady', function() {
    
      
      // Add elements in array in format ['FieldName', '[@ParameterName]'], 
    
      var elements = [
        ['cas1', '[@Virtual1]'],
        ['cas2', '[@Virtual2]'],
        ['cas3', '[@Virtual3]'],
        // ['cas4', '[@Virtual4]'],
      ]
      
      // Add elements in array in format ['FieldName', '[@ParameterName]'], 
    
    
    
      elements.reverse();
      elements.forEach(function(elem, idx) {
        var element = document.querySelector(`[id*=InlineAdd${elem[0]}]`);
        addCasChangeHandler(element, elem[1]);
    
        if(idx == elements.length - 1)
          element.dispatchEvent(new Event("change"));
          
      })
    
    })
    
    function addCasChangeHandler(elem, value) {
      elem.addEventListener('change', function(e) {
        var t = e.target;
        console.log(t);
        t.dispatchEvent(ev_md);
        
        var db = document.querySelector(`.DropBox`);
        
        var observer = new MutationObserver( function(mutationsList, observer) {
         mutationsList.forEach( function(mutation, idx){
          console.log(mutation);
          if(mutation.target == db) {
            console.log("Yes!");
            console.log(value);
            var opt = document.querySelector(`.DropBox .Option[title="${value}"]`);
            if(opt) opt.click(); else t.dispatchEvent(ev_md);
            observer.disconnect();
          }
          
          t.click();
         });
        });
        
        observer.observe(db, {attributes: true, childList: true, subtree: true})
        
      })
    }
    
    
    </script>

     

    Hope this helps, in any way.

    [src="carl.js"]

  3. Hello @NickO,

     

    Search (included) and Results uses a different DOM IDs naming convention compared to Submission Form.

     

    Cascading Dropdowns usually take a few seconds to load asyncrhronously (depending on your network speed), and before this happens, the script had already ran.

    The solution to this would be to set a delay before your browser runs this line of code.

    <script>
    setTimeout(function() {
    document.querySelector('[id*=]').value = "[@FeatureID]";
    }, 1000)
    </script>

     

    Not entirely certain what your use-case is but I hope this algorithm works.

    Note: if you are using this on Forms, I recommend putting this in an HTML Block that is positioned at the very bottom (so that the fields are already written to the DOM before the script runs).

     

    [src="carl.js"]

  4.  

    On 11/17/2018 at 7:45 PM, DefinitelyNot31337 said:

     

    
    <button type="button" onclick="resetForm()">Clear Form</button>
    
    
    <script>
    function resetForm() {
      
        var myForm = document.querySelectorAll('form[action*="[@cbAppKey]"] input[type=text]');
        myForm.forEach(function(elem) {
        elem.value="";
      });
    }
    </script>

     


    Hello y'all,

     

    This solution is great. I have tested it. However, on my use case, I had dropdowns and textareas which were not affected by the reset.

    I just wanted to share an updated code that will affect such.

    <button type="button" onclick="resetForm()">Clear Form</button>
    
    
    <script>
    function resetForm() {
      
        var myForm = document.querySelector('form[action*="[@cbAppKey]"]').querySelectorAll('input:not([type=submit]):not([type=hidden]), textarea, select');
        myForm.forEach(function(elem) {
        elem.value="";
      });
    }
    </script>

     

    [src="carl.js"]

  5. On 10/4/2019 at 4:31 AM, rgiljohann said:

    Thanks @Andrew. I will give this a try as it might work for this situation. I generally try to stay away from Iframe, because even this function is sending a parameter through a URL string. Is there anyway to find the ID on load? I tried the script below but could not figure out the correct syntax for finding the ID.

     

    Hello guys,

     

    Try using this line of code.

    var chart = Highcharts.charts[+document.querySelector('[action*="[@cbAppKey]"] .highcharts-container').id.replace('highcharts-', '')]

     

    Works on my end. Hope this works on yours too.

     

    [src="carl.js"]

  6. Hi @NeoInJS,

     

    You may try pasting the code snippet provided in an HTML Block.

    (Note: Disable the HTML Editor from the Advanced tab, and move the HTML Block to the very bottom).

     

    Note that we can add/remove items in the fields arrayWe can add DataSource fields as well. Just duplicate field lines as needed and put cbParamVirtualn, or the name of your DataSource field.

    <script>
      var fields = [
        'cbParamVirtual1',
        'cbParamVirtual2',
        'cbParamVirtual3',
        'cbParamVirtual4',
      ];
      
      
      /*
       * 
       * Do not modify code from beyond this point
       */
      fields = fields.map( function(elem) {
        return document.querySelector('[action*="[@cbAppKey]"] [id*='+ elem + ']');
      });
    
     
    
      function changer(ev) {
        fields.forEach(function(field) {
          if (ev.target.value != '' && ev.target != field)
            field.value = '';
        });
      }
    
     
    
      fields.forEach(function(fff) {
        fff.addEventListener('change', changer);
      });
      
    </script>

     

    [src="carl.js"]

×
×
  • Create New...