Help center JavaScript cookbook

Return to top

6 Comments

  • Shawn Amsberry

    Is it possible to autofill a field that is a dropdown menu field?  Or does that only work for text entry fields?  I can successfully hide fields on various forms and autofill text fields like the subject and description, but I have not been successful with drop menus.

    Thanks!

    0
  • Cheeny Aban
    Zendesk Customer Care
    Hi Shawn,

    Are you trying to autofill a dropdown field on a ticket form? If yes, the Creating pre-filled ticket forms will help you
    0
  • Adam

    Hello,

    I'm looking for help on ticket forms in the Help Center. We currently have a URL in the description of a custom field. This allows our customer to reference the information on this page while filling out the form.

    The issue we have discovered is that when the customer clicks on the link it opens the URL in the same window as the Help Center. 

    Does anyone one know how to capture this via Javascript and force the link to open into a new tab within the users browser?

    0
  • DJ Buenavista Jr.
    Zendesk Customer Care
    Hi Adam,
     
    In regards to your concern, the following script involves custom coding. I would advise searching online for solutions, but I have found some from looking online. 
     
    You can check an example from StackOverflow, here. Another one for reference can be found here. 
     
    Thank you and have a wonderful day ahead!
     
     
    Kind regards,
    0
  • Adam

    Hey DJ Buenavista Jr.

    Thank you for your recommendation.

    I was able to find another solution with one of our Javascript engineers and is working as expected. I'll certainly keep the options you've shared in my back pocket if I have any issues with the one I'm using.

    const links = document.querySelectorAll("a");
      for (const link of links) {
        link.addEventListener('click', function (e) {
        if (e.target.href == 'http://google.com') {
            e.preventDefault();
            window.open(link.href, '_newtab' + Date.now());
          }
        });
    }
    0
  • DJ Buenavista Jr.
    Zendesk Customer Care
    Hi Adam,
     
    I'm glad to hear that you were able to find a suitable solution. Please don't hesitate to reach out anytime if you need further help or questions. 

    Have a wonderful day ahead!
     
     
     
    Kind regards, 
    0

Please sign in to leave a comment.

Powered by Zendesk