I'm trying to create a button so that when clicked, a specific element stored in an associative array will get deleted. But what I've done doesn't seem to work. Any help will be appreciated.    // Creates the button   bodyText = bodyText + '&lt;input type="button" id="btnDeleteQuestion"    value="Delete a question"&gt;';    document.getElementById("btnDeleteQuestion")     .addEventListener("click", function() {       // Deletes the third question stored in the questionBank       delete questionBank[2]['questionText'];       console.log(questionBank);       }); }
81666
How do I remove the key 'bar' from an array foo so that 'bar' won't show up in  for(key in foo){alert(key);}
107908
I have began developing a button to automatically close the current case but I can't seem to get it working. I have tried a few different approaches but would someone be able to point me in the right direction.  As it stands the button does nothing, I feel like im on the right track, looking for someone who has done something similar with regards to updating fields from within a lightning component.   CMP  &lt;aura:component controller="AmexComm_SecureMsgController" implements="forceCommunity:availableForAllPageTypes,force:hasRecordId" access="global"&gt; &lt;aura:attribute name="record" type="Case"/&gt; &lt;aura:attribute name="caseStatus" type="String"/&gt; &lt;aura:attribute name="caseId" type="String" default="{!v.recordId}"/&gt;  &lt;aura:handler name="init" value="{!this}" action="{!c.doInit}"/&gt;   &lt;button class="slds-button slds-button--neutral newsbutton" style="float:right"  onclick="{!c.closeCase}"&gt;Close Case&lt;/button&gt;   AmexComm_SecureMsgController   @AuraEnabled     public static Case getCase(Id caseId){         return([Select id, Atrium_Subject__c, Atrium_AmexSubject__c, Status, Atrium_Message_Status__c, Contact.Name, ContactId, CreatedDate, Message_Number__c, LastModifiedDate, Description__c,                 (SELECT id, Name From Attachments)                                 From Case Where id=:caseId]);     }     @AuraEnabled     public static Case closeCase(Case caseA){        update caseA;        return caseA;     }   Controller  { doInit : function(component, event, helper) {     component.set("v.isError", false)     component.set("v.showEditView", false);     component.set("v.errorMsg", "");      var action = component.get("c.getCase");     action.setParams({         caseId : component.get("v.caseId")     });      action.setCallback(this, function(a) {         if (a.getState() === "SUCCESS") {             component.set("v.record", a.getReturnValue());             helper.getStatusPickListValue(component);         }     });      $A.enqueueAction(action); },  closeCase : function (component, event, helper) {     var action = component.get("c.closeCase");     var Status = component.get("v.record.Status") //get value of field     //console.log("Status: " Status);     action.setParams({Status : Closed});      $A.enqueueAction(action); },   Helper  getStatusPickListValue : function(component) {          var action = component.get("c.getCaseStausPickList");         action.setCallback(this, function(response) {             var state = response.getState();             var hasImg = false;             if (component.isValid() &amp;&amp; state === "SUCCESS") {                  var statusPickList = response.getReturnValue();                 component.set("v.lstCaseStatus", statusPickList);                  console.log('status picklist ::', component.get("v.lstCaseStatus"));             }         });         $A.enqueueAction(action);      },
94823
I am trying to create a button which will update a field value to null (RESET it). However, it's not working and not even giving any error. So when I click on the button, nothing happens.  lc.cmp:  &lt;aura:attribute name="myObj" type="Account" default="{'SObject':'Account'}"/&gt; &lt;lightning:input type="text" name="accountPhn" label="Enter Account Phone" value="{!v.myObj.Name}"/&gt; &lt;lightning:button label="Reset" onclick="{!c.resetMe}"/&gt;   lc.js:  resetMe : function(component, event, helper) {         //alert("Called");         component.set("v.accountPhn","");     }   Appreciate help around this.
6261
I am looking for a JavaScript array insert method, in the style of:  arr.insert(index, item)   Preferably in jQuery, but any JavaScript implementation will do at this point.
33592
I have a group of strings in Javascript and I need to write a function that detects if another specific string belongs to this group or not.  What is the fastest way to achieve this? Is it alright to put the group of values into an array, and then write a function that searches through the array?  I think if I keep the values sorted and do a binary search, it should work fast enough. Or is there some other smart way of doing this, which can work faster?
40506
I am writing a function that adds an ID number to an array and puts the array in the usermeta. $_GET['auction'] is the post_id.  Below is the function:  $reminders = get_user_meta( $current_user-&gt;ID, "reminders" ); print_r( $reminders ); if( in_array( $_GET['auction'], $reminders ) ) {     echo "Failed: Auction already in list"; } else {     array_push( $reminders, intval( $_GET['auction'] ) );     if ( update_user_meta( $current_user-&gt;ID, "reminders", $reminders ) ) {         echo "Success";     } else {         echo "Failed: Could not update user meta";     } } print_r( $reminders );   Here is the output after adding one auction:  Array ( )  Success Array ( [0] =&gt; 7 )    Here is the output after adding two auctions:  Array ( [0] =&gt; Array ( [0] =&gt; 7 ) )  Success Array ( [0] =&gt; Array ( [0] =&gt; 7 ) [1] =&gt; 73 )   And here is the output after adding three auctions:  Array ( [0] =&gt; Array ( [0] =&gt; Array ( [0] =&gt; 7 ) [1] =&gt; 73 ) )  Success Array ( [0] =&gt; Array ( [0] =&gt; Array ( [0] =&gt; 7 ) [1] =&gt; 73 ) [1] =&gt; 0 )   Notice that adding a new element to the array using array_push works fine. But when the array is stored in the usermeta then retrieved again, the last element in the array has been put into an array of its own, creating an infinitely dimensional array. I'd prefer to keep this array one dimensional.  Is there a way I can run update_user_meta and get_user_meta without it changing the structure of my array?
32675
I have a VF page that is the 'edit' page for a certain object. I have a button 'Clone'. Upon clicking this button, I wish to be redirected to a new edit page with all the previous objects fields still intact (except for a few that should be cleared and set to default). Note that this new object should not be inserted until I click 'Save'. The Id of the object should be different compared to the previous object, so that on Save, the previous object is not overwritten.   I am thinking I will split this up into two parts, an apex method, and a javascript method for resetting the fields:  &lt;apex:commandButton action="{!saveAsTemplate}" onclick="initTemplate();" value="Clone" /&gt;   The javascript portion is easy enough, but I'm having trouble of figuring out what to do on the apex side, besides for setting the id of the record to null.
25150
This is a question that's been nagging me for some time. I always thought that C++ should have been designed so that the delete operator (without brackets) works even with the new[] operator.  In my opinion, writing this:  int* p = new int;   should be equivalent to allocating an array of 1 element:  int* p = new int[1];   If this was true, the delete operator could always be deleting arrays, and we wouldn't need the delete[] operator.  Is there any reason why the delete[] operator was introduced in C++?  The only reason I can think of is that allocating arrays has a small memory footprint (you have to store the array size somewhere), so that distinguishing delete vs delete[] was a small memory optimization.
12181
Is there a best-practice or common way in JavaScript to have class members as event handlers?  Consider the following simple example:  &lt;head&gt;     &lt;script language="javascript" type="text/javascript"&gt;          ClickCounter = function(buttonId) {             this._clickCount = 0;             document.getElementById(buttonId).onclick = this.buttonClicked;         }          ClickCounter.prototype = {             buttonClicked: function() {                 this._clickCount++;                 alert('the button was clicked ' + this._clickCount + ' times');             }         }      &lt;/script&gt; &lt;/head&gt; &lt;body&gt;     &lt;input type="button" id="btn1" value="Click me" /&gt;     &lt;script language="javascript" type="text/javascript"&gt;         var btn1counter = new ClickCounter('btn1');     &lt;/script&gt; &lt;/body&gt;   The event handler buttonClicked gets called, but the _clickCount member is inaccessible, or this points to some other object.  Any good tips/articles/resources about this kind of problems?
41510
Attempting to delete questions on the mobile site on iOS causes two notification messages asking me to confirm the deletion, which it shouldn't do.  I haven't really looked into it, but it may just be that the handlers from full.js and mobile.js are both being triggered, as there seems to be the flash of the error dialog indicating something went wrong on the supposed second AJAX request when the response from the first triggers a page reload.  You can see this happening by following the method calls; the mobile view first calls   StackExchange.question.init() -&gt; StackExchange.question.fullInit()   -&gt; StackExchange.vote.init()     -&gt; u()    ...where u() sets a delegated click handler on  $("div.post-menu *[id^='delete-post-'], table.flagged-posts *[id^='delete-post-']")   ...that calls .preventDefault() on the event, but doesn't block other handlers from firing.  It then later calls StackExchange.mobile.init(), which in turn calls the method J() that sets up a similar handler directly on $(".delete-post").  Since both handlers get triggered, there's two confirmation dialogs, and two attempts to delete the post. The extra handler in mobile.js seems unnecessary, so just removing it would appear to be the easy fix to the problem.
59647
I'm using the 1-25-19 version of 2.8 beta. You have to double tap "a" every time you want to deselect something which is very annoying. Is there a way to make "a" work the old way where "a" selects all if nothing is selected and "a" deselects all if something is selected? ie. no double tap and no alt?
98687
If the user selects an option in a dropdown box, there must be added a label and a textbox. Using appendChild, these elements get added to the end of the container.  var newFreeformLabel = document.createElement('label'); newFreeformLabel.innerHTML = 'Omschrijving:';  var newFreeformField = document.createElement('input'); newFreeformField.className = 'textfield'; newFreeformField.name = 'factuur_orderregel[]';  var newFreeformSpacer = document.createElement('div'); newFreeformSpacer.className = 'spacer';  container.appendChild(newFreeformLabel); container.appendChild(newFreeformField); container.appendChild(newFreeformSpacer);   The issue is that these elements should be inserted at the beginning of container, not at the end.  Is there a solution to this in PrototypeJS?
31158
Let's say I have an html form.  Each input/select/textarea will have a corresponding &lt;label&gt; with the for attribute set to the id of it's companion. In this case, I know that each input will only have a single label.  Given an input element in javascript &mdash; via an onkeyup event, for example &mdash; what's the best way to find it's associated label?
71962
I have an element with an onclick method.  I would like to activate that method (or: fake a click on this element) within another function.  Is this possible?
9012
I'd like to make a click event fire on an &lt;input type="file"&gt; tag programmatically.  Just calling click() doesn't seem to do anything or at least it doesn't pop up a file selection dialog.  I've been experimenting with capturing events using listeners and redirecting the event, but I haven't been able to get that to actually perform the event like someone clicked on it.
110595
I am trying to save multiple values from a textarea to a database table.  I use the following code, but I feel it is the wrong way.   foreach ($user_emails as $key =&gt; $value) {   $insert_banned_emails = db_insert('banned_users');   $insert_banned_emails     -&gt;fields(array(       'email' =&gt; $value,     ))     -&gt;execute(); }   Is there a different way for achieving the same result?
70777
I have an afterInsert trigger on Events. When the Script is finished, I would like to delete the event. I keep getting this error message.     DML statement cannot operate on Trigger.new or Trigger.old   If I cannot do this within Trigger.new, what is the best way to do this? If SOQL is involved, what field am I looking for? event.ID?