We help IT Professionals succeed at work.

javascript - insert into js doc help

sj77 asked
Last Modified: 2017-03-20
Hello, Experts,

I have a block of code that has a drop down box in a page. It is currently showing a list of different categories when you drop down.

I was given code, without instruction of where to insert, and I feel like a deer staring at headlights. Can you guide me?

Current existing code:

* jQuery v1.9.1 included
$(document).ready(function() {
  // social share popups
  $(".share a").click(function(e) {
    window.open(this.href, "", "height = 500, width = 500");
  // show form controls when the textarea receives focus or backbutton is used and value exists
  var $commentContainerTextarea = $(".comment-container textarea"),
  $commentContainerFormControls = $(".comment-form-controls, .comment-ccs");
  $commentContainerTextarea.one("focus", function() {
  if ($commentContainerTextarea.val() !== "") {
  // Expand Request comment form when Add to conversation is clicked
  var $showRequestCommentContainerTrigger = $(".request-container .comment-container .comment-show-container"),
    $requestCommentFields = $(".request-container .comment-container .comment-fields"),
    $requestCommentSubmit = $(".request-container .comment-container .request-submit-comment");
  $showRequestCommentContainerTrigger.on("click", function() {
  // Mark as solved button
  var $requestMarkAsSolvedButton = $(".request-container .mark-as-solved:not([data-disabled])"),
    $requestMarkAsSolvedCheckbox = $(".request-container .comment-container input[type=checkbox]"),
    $requestCommentSubmitButton = $(".request-container .comment-container input[type=submit]");
  $requestMarkAsSolvedButton.on("click", function () {
    $requestMarkAsSolvedCheckbox.attr("checked", true);
    $requestCommentSubmitButton.prop("disabled", true);
    $(this).attr("data-disabled", true).closest("form").submit();
  // Change Mark as solved text according to whether comment is filled
  var $requestCommentTextarea = $(".request-container .comment-container textarea");
  $requestCommentTextarea.on("keyup", function() {
    if ($requestCommentTextarea.val() !== "") {
      $requestCommentSubmitButton.prop("disabled", false);
    } else {
      $requestCommentSubmitButton.prop("disabled", true);
  // Disable submit button if textarea is empty
  if ($requestCommentTextarea.val() === "") {
    $requestCommentSubmitButton.prop("disabled", true);
  // Submit requests filter form in the request list page
  $("#request-status-select, #request-organization-select")
    .on("change", function() {
  // Submit requests filter form in the request list page
  $("#quick-search").on("keypress", function(e) {
    if (e.which === 13) {
  function search() {
    window.location.search = $.param({
      query: $("#quick-search").val(),
      status: $("#request-status-select").val(),
      organization_id: $("#request-organization-select").val()
  $(".header .icon-menu").on("click", function(e) {
    var menu = document.getElementById("user-nav");
    var isExpanded = menu.getAttribute("aria-expanded") === "true";
    menu.setAttribute("aria-expanded", !isExpanded);
  if ($("#user-nav").children().length === 0) {
    $(".header .icon-menu").hide();
  // Submit organization form in the request page
  $("#request-organization select").on("change", function() {
  // Toggles expanded aria to collapsible elements
  $(".collapsible-nav, .collapsible-sidebar").on("click", function(e) {
    var isExpanded = this.getAttribute("aria-expanded") === "true";
    this.setAttribute("aria-expanded", !isExpanded);

Open in new window

New code:

$(window).load(function() {
   var i = 0;
   var cZendesk = false; //assume user is not part of the BlueBerry Organization
   //reserve space for additional organizations
   var checkExist = setInterval(function() {
      if ($("a.nesty-input").length){
         $("a.nesty-input").each(function() {
            $(this).bind( "click", function() {
               for (var c in HelpCenter.user.organizations) {
                  if (HelpCenter.user.organizations[c].name == "Automotive Technicians"){
                     cZendesk = true; //if user is part of the organization called "Automotive Technicians", then set its variable to true.
                  //reserve space for additional organizations
                  if (!cZendesk){
                     $("#577128").remove(); //replace the "TICKET_FORM_ID" with the proper id from the dropdown list. Leave the pound sign intact.
            //reserve space for additional organizations
      if (i > 10){
   }, 100);

Open in new window

Watch Question

Distinguished Expert 2017

Can you post HTML code?
Most Valuable Expert 2017
Distinguished Expert 2019
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions