I often see html elements with an onchange attribute that specifies javascript as the language, e.g.:  onchange="javascript:updateModel()"   It still works if I remove javascript:  onchange="updateModel()"   Is it safe to remove it? Are there some browsers (maybe older versions) that need it?
30377
AFAIK, you never need to specify the protocol in an onclick:  onclick="javascript:myFunction()" Bad  onclick="myFunction()" Good  Today I noticed in  on Google Anallytics that they are using it:  &lt;a href="http://www.example.com" onClick="javascript: pageTracker._trackPageview('/outgoing/example.com');"&gt;   Is this example just plain wrong, or is there ever a reason to specify javascript: in anything other than a href?
366
Let's say we have this code for a LWC:  &lt;!-- helloExpressions.html --&gt; &lt;template&gt;     &lt;div class="slds-m-around_medium"&gt;         &lt;lightning-input name='firstName' label="First Name" onchange={handleChange}&gt;&lt;/lightning-input&gt;         &lt;lightning-input name='lastName' label="Last Name" onchange={handleChange}&gt;&lt;/lightning-input&gt;         &lt;p class="slds-m-top_medium"&gt;Uppercased Full Name: {uppercasedFullName}&lt;/p&gt;     &lt;/div&gt; &lt;/template&gt;   and this is the JS file:  // helloExpressions.js import { LightningElement, track } from 'lwc';  export default class HelloExpressions extends LightningElement {     @track firstName = '';     @track lastName = '';      handleChange(event) {         const field = event.target.name;         if (field === 'firstName') {             this.firstName = event.target.value;         } else if (field === 'lastName') {             this.lastName = event.target.value;         }     }      get uppercasedFullName() {         return `${this.firstName} ${this.lastName}`.toUpperCase();     } }   firstName and lastName have been decorated with @track. Now as per the documentation, decorating a property with @track makes it private and reactive, while to mark a property public and reactive, use @api.  So if I just change the decorator to @api for both these variables, it should work. I am referring these from the same component only. But it's not working.  UPDATE: 27th Feb -------------------- Somehow it's working today. I just changed the decorator of the variables to api.  import { LightningElement, api } from 'lwc';  export default class HelloExpressions extends LightningElement {     @api firstName = '';     @api lastName = '';      handleChange(event) {         const field = event.target.name;         if (field === 'firstName') {             this.firstName = event.target.value;         } else if (field === 'lastName') {             this.lastName = event.target.value;         }     }      get uppercasedFullName() {         return `${this.firstName} ${this.lastName}`.toUpperCase();     } }   So it's working.
74715
I have several input and option elements on my page, each (well almost) have an event attached to update some text on the page once they change. I use jQuery which is really really cool :)   I also use Microsofts  framework, utilizing the UpdatePanel. The reason why I do that is that certain elements are created on the page based on some server-side logic. I don't really want to explain why I use the UpdatePanel - even if it could (it can with quite some effort) be rewritten to use only  I still want that UpdatePanel.  You probably guessed it - once I have a postback on the UpdatePanel the jQuery events stops working. I actually was expecting this, since the "postback" is not really a new postback so my code in document.ready that binds the events won't be fired again. I also confirmed my suspicion by reading up on it in the jQuery help libraries.  Anyway I'm left with the problem of rebinding my controls after the UpdatePanel is done updating the . I preferably need a solution that does not require adding more .js files (jQuery plug-ins) to the page but something as simple as being able to catch the UpdatePanel's 'afterupdating' where I can just call my method to rebind all the form elements.
41418
I made the mistake to translate the Drupal interface in my local language. But since the language is set into the database, I can't delete this language using the Drupal UI. And I'm not sure which file(s) to delete in the database.    Does anyone know a (faultlessly) way to translate the Drupal interface back to English?
106850
When using the xhtml1-transitional.dtd doctype, collecting a credit card number with the following HTML  &lt;input type="text" id="cardNumber" name="cardNumber" autocomplete='off'/&gt;   will flag a warning on the W3C validator:     there is no attribute "autocomplete".   Is there a W3C / standards way to disable browser auto-complete on sensitive fields in a form?
29087
/**  * Implements hook_form_alter().  */ function MODULE_NAME_form_alter(   &amp;$form,   \Drupal\Core\Form\FormStateInterface $form_state,   $form_id ) {    if ($form_id == 'node_article_form') {     $form["body"]["widget"][0]['#allowed_formats'] = ['full_html']; // Your default format     $form["body"]["widget"][0]['#after_build'][] = 'MODULE_NAME_hide_format';   } }  function MODULE_NAME_hide_format(   &amp;$element,   FormStateInterface $form_state ) {   if (isset($element["format"]["format"])) {     $element["format"]["format"]["#access"] = FALSE;   }    return $element; }
15704
I know it's of course a dispute whether or not to support foreign languages on StackOverflow. However, my question is a bit different.  is in English, but has code with comments and identifiers in a foreign language. This limits the ability for people to leave answers.  Despite the fact that the example question I linked is poor regardless of language barrier, how should we [the users] handle such questions? Should we...   Accept them into StackOverflow and try to translate them? Cast close votes because we cannot understand to answer? Ask the OP to translate it to English for us? Wait for someone else to come translate it for us?   The same also applies when the code its self includes identifiers in a foreign language. In case this original question I linked gets deleted, here's the source from that question:  procedure TForm1.Button1Click(Sender: TObject); var   X: Integer; begin   for x := 1 to 5 do     if Sender = Botones[x] then //Valida el Boton que provoco el evento     begin       Codigo := x;   //Captura la posicion donde se eonctro el objeto que generó el evento       // ShowMessage(IntToStr(x));       Exit; //sale del bucle     end; end;
3752
I have PHP configured so that magic quotes are on and register globals are off.  I do my best to always call htmlentities() for anything I am outputing that is derived from user input.  I also occasionally seach my database for common things used in xss attached such as...  &lt;script   What else should I be doing and how can I make sure that the things I am trying to do are always done.
869
Are CDATA tags ever necessary in script tags and if so when?  In other words, when and where is this:  &lt;script type="text/javascript"&gt; //&lt;![CDATA[ ...code... //]]&gt; &lt;/script&gt;   preferable to this:  &lt;script type="text/javascript"&gt; ...code... &lt;/script&gt;
104333
i am trying to set value to the lightning:inputField using the value attribute. The value attribute seems to work during the init handler event of the component. however i have a onchange for lightning:select . i want to set a custom value to the lightning:inputField(example, component.find("name").set("v.value","testing")). but it doesnt seem to work. however i noticed from console.log, the value attribute is getting changed but it doesnt reflect neither in UI nor while saving to the DB.
92375
Here's an example I just ran into. I'm trying to put some HTML in the label of my field.  $form['field_feedback']['und']['#title'] &lt;- has the title $form['field_feedback']['und'][0]['#title'] &lt;- has the title $form['field_feedback']['und'][0]['value']['#title'] &lt;- has the title. (Works)   Why are there three populated #title attributes with only one being used?
109025
Let's say I have a Lightning-Web-Component with a select list with dynamic options where the value is a user Id and the label is the user's name:  &lt;select class="slds-select" onchange={handleSelectChange} disabled={isDisabled}                           data-value={step.selectedUser} &gt;                                 &lt;option value=""&gt;--None--&lt;/option&gt;                                 &lt;template for:each={step.approvalTemplateStep.Approval_Step_Users__r} for:item="user"&gt;                                     &lt;option key={user.key} value={user.User__c}&gt;                                         {user.User__r.Name}&lt;/option&gt;                                 &lt;/template&gt;                             &lt;/select&gt;    How do I prepopulate the select option with a value? I have the value I want to be prepopulated in the variable called step.selectedUser.  Here's what I see on page load:   Here's what I should see:
92799
Several of my pages use both JQuery and Protoype. Since I upgraded to version 1.3 of JQuery this appears to be causing problems, because both libraries define a function named '$'.  JQuery provides a function noConflict() which relinquishes control of $ to other libraries that may be using it. So it seems like I need to go through all my pages that look like this:  &lt;head&gt;           &lt;script type="text/javascript" src="/obp/js/prototype.js"&gt;&lt;/script&gt;     &lt;script type="text/javascript" src="/obp/js/jquery.js"&gt;&lt;/script&gt; &lt;/head&gt;   and change them to look like this:  &lt;head&gt;           &lt;script type="text/javascript" src="/obp/js/prototype.js"&gt;&lt;/script&gt;     &lt;script type="text/javascript" src="/obp/js/jquery.js"&gt;&lt;/script&gt;     &lt;script type="text/javascript"&gt;         jQuery.noConflict();         var $j = jQuery;     &lt;/script&gt; &lt;/head&gt;   I should then be able to use '$' for Prototype and '$j' (or 'jQuery') for JQuery. I'm not entirely happy about duplicating these 2 lines of code in every relevant page, and expect that at some point somebody is likely to forget to add them to a new page. I'd prefer to be able to do the following    Create a file jquery-noconflict.js which "includes" jquery.js and the 2 lines of code shown above Import jquery-noconflict.js (instead of jquery.js) in all my JSP/HTML pages   However, I'm not sure if it's possible to include one JS file in another, in the manner I've described? Of course an alternate solution is simply to add the 2 lines of code above to jquery.js directly, but if I do that I'll need to remember to do it every time I upgrade JQuery.
100473
Warning: The type attribute is unnecessary for JavaScript resources.     From line 10, column 146; to line 10, column 176     feed/&quot; /&gt; &lt;script type=&quot;text/javascript&quot;&gt;window      Warning: The type attribute for the style element is not needed and should be omitted.     From line 11, column 1798; to line 11, column 1820     &lt;/script&gt; &lt;style type=&quot;text/css&quot;&gt;img.wp      Warning: The type attribute for the style element is not needed and should be omitted.     From line 23, column 193; to line 23, column 251     a='all' /&gt;&lt;style id='kirki-styles-global-inline-css' type='text/css'&gt;.envel      Warning: The type attribute is unnecessary for JavaScript resources.     From line 23, column 905; to line 23, column 1010     }&lt;/style&gt; &lt;script async type=&quot;text/javascript&quot; src=&quot;http://....../wp-content/cache/minify/df983.js&quot;&gt;&lt;/scri      Warning: The type attribute for the style element is not needed and should be omitted.     From line 70, column 126; to line 70, column 167     70.png&quot; /&gt;&lt;style type=&quot;text/css&quot; id=&quot;wp-custom-css&quot;&gt;@media      Warning: The type attribute is unnecessary for JavaScript resources.     From line 441, column 156; to line 441, column 261     iv&gt;&lt;/div&gt; &lt;script defer type=&quot;text/javascript&quot; src=&quot;http://......./wp-content/cache/minify/26938.js&quot;&gt;&lt;/scri      Warning: The type attribute is unnecessary for JavaScript resources.     From line 441, column 272; to line 441, column 302     &lt;/script&gt; &lt;script type='text/javascript'&gt;/*  */      Warning: The type attribute is unnecessary for JavaScript resources.     From line 443, column 17; to line 443, column 122     &lt;/script&gt; &lt;script defer type=&quot;text/javascript&quot; src=&quot;http://......../wp-content/cache/minify/6ce07.js&quot;&gt;&lt;/scri  These errors are some new introduction by W3C and they have started to creep in last 3-4 days only. We enqueue scripts like this → wp_register_script( 'custom-js', get_template_directory_uri() . '/js/custom.js', array( 'jquery' ), '1.1', true );     wp_enqueue_script( 'custom-js' );  Can we fix this from the above enqueuing method somehow? Update → these are the actual errors. In the red box are coming from W3 total cache.
75034
I have an input form that lets me select from multiple options, and do something when the user changes the selection. Eg,  &lt;select onChange="javascript:doSomething();"&gt;   &lt;option&gt;A&lt;/option&gt;   &lt;option&gt;B&lt;/option&gt;   &lt;option&gt;C&lt;/option&gt; &lt;/select&gt;   Now, doSomething() only gets triggered when the selection changes.  I want to trigger doSomething() when the user selects any option, possibly the same one again.  I have tried using an "onClick" handler, but that gets triggered before the user starts the selection process.  So, is there a way to trigger a function on every select by the user?  Update:  The answer suggested by Darryl seemed to work, but it doesn't work consistently. Sometimes the event gets triggered as soon as user clicks the drop-down menu, even before the user has finished the selection process!
32885
I have some html like this:  &lt;div id="1"&gt;     &lt;p&gt;         Volume = &lt;input type="text" /&gt;         &lt;button rel="3.93e-6" class="1" type="button"&gt;Check answer&lt;/button&gt;     &lt;/p&gt;     &lt;div&gt;&lt;/div&gt; &lt;/div&gt;   and some JS like this:  $("button").click(function () {     var buttonNo = $(this).attr('class');     var correct = Number($(this).attr('rel'));      validate (Number($("#"+buttonNo+" input").val()),correct);     $("#"+buttonNo+" div").html(feedback); });   What I'd really like is if I didn't have to have the class="1" on the button (I know numeric classes aren't valid, but this is a WIP!), so I could determine buttonNo based on the id of the parent div. In real life there are multiple sections looking like this.   How do I find the id of the div parenting the button. What would be a more semantic way to store the answer in the button code. I want to make this as foolproof as possible for a non programmer to copy and paste without breaking things!
45898
Say, there's a Java (C#, Javascript, etc) question involving array and tagged only 'java'. Two months ago nobody would lift a finger to add 'arrays' tag: the benefit is tiny, if it exists at all.  Yet, last few days I've been noticing a lot of such edits and not sure what to do. Some users even go on retagging rampage, updating every question they can lay their hands on (you can see them repeatedly in the list of pending edits).  I don't mind those guys getting their lousy 1000 reputation this way (well, only a little), but somehow I feel that the system was intended for slightly more substantial changes.    What would you do in this case? Approve or reject?  PS Some examples from the last few minutes