Jump to content

Search the Community

Showing results for tags 'scope'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Found 4 results

  1. Hello, I started learning JavaScript this week and I've been mostly using the JavaScript tutorial. It's been great, thanks a lot to all the authors! However, unless I'm mistaken and still don't fully understand, there is some information that I think is wrong or misleading about variable scopes. It prevented me from understanding closures until I worked through other people's code about main loops and did some testing. On the Function Closures page, it says: "Local variables have short lives. They are created when the function is invoked, and deleted when the function is finished." And on the Scope page, it says something similar: "Local variables are deleted when the function is completed." But a local variable is not deleted when the function is completed if there is a reference to it left somewhere outside the function. Of course, normally, there are no references to local variables left outside a function so the local variables are deleted upon exit. But when we declare a local subfunction that access a local variable and then give this subfunction to an outside object, so long as the outside object exist, the local variable of the original function will not be deleted either because it can still be accessed. I think this exception should be mentioned on both pages to help beginners (like me) understand how a local variable can still be accessed after the function is was declared in has been completed. I have some prior experience in C and VBA and I find the scopes of variables in JavaScript to be very different (probably due to not having a way of passing non-object variable references in function arguments). Or maybe I'm wrong, in which case I would be grateful if someone can explain it to me further. Thanks Terence
  2. GENERAL QUESTION: Can variables created outside of a function be used within a function without having to read them first as arguments of the function? If so, can a function created within a function use a variable created outside of both functions? CODE var dataString = 'search_input=' + search_letter_input; $.ajax({ type: "POST", url: './...', data: dataString, dataType: 'JSON', statusCode: { 404: function() { alert( "Page not found" ); }}, success: function(jsonData) {...} }); SPECIFIC QUESTION: I would like to use the value of the variable search_letter_input in the success function of the $.ajax( ) method. Is this possible? Roddy
  3. Hello everybody, I'm new in angular so sorry if my question is ridiculous. I have a drag and drop file area and when I put a file I put his details (attributes: name, size, type) on inputs disabled because I don't want that users can change them. All of that is a form, so I want to save this with angular in scopes. Here my code: <div ngf-drop ngf-select ng-model="files" class="drop-box" ngf-drag-over-class="'dragover'" ngf-multiple="true" ngf-allow-dir="true" accept="{{acceptSelect}}" ngf-pattern="pattern" required>Arrastre y suelte su archivo aquí</div> <div ngf-no-file-drop>File Drag/Drop is not supported for this browser</div> <br> <div class="preview"> <div>Detalles del video: <div style="clear:both" class="videodetails" ng-repeat="file in files"> <div class="form-group"> <label class="col-md-4 control-label" for="fileName">{{ "Nombre" }}</label> <div class="col-md-5"> <input id="fileName" type="text" ng-model="file.name" disabled> </div> </div> <div class="form-group"> <label class="col-md-4 control-label" for="fileSize">{{ "Tamaño" }}</label> <div class="col-md-5"> <input id="fileSize" type="text" ng-model="file.size" disabled> </div> </div> <div class="form-group"> <label class="col-md-4 control-label" for="fileType">{{ "Tipo" }}</label> <div class="col-md-5"> <input id="fileType" type="text" ng-model="file.type" disabled> </div> </div> JavaScript: $scope.file = function (data) { $scope.file.fileName = data.name; $scope.file.fileSize = data.size; $scope.file.fileType = data.type; } I don't know what I'm doing wrong. Any help? Does anybody know to fix it? Thank you very much!
  4. Hi guys, I just have a dumb question but looks like I can't find the answer anywhere at all. What is a global function? specifically, how do I determine the scope of a function? I know the definition of the variable scope, but function scope, I don't, hope you guys could clarify this for me. One more thing. I have this code down below about the "this" keyword. Doesn't the "this" keyword refer to the element that triggers the event? if so, why it pops up "undefined" when I click on the paragraph? I'm pretty positive "this" in my case is bound to a global variable(that's why it gives me an "undefined" id) which is the window object, but I don't understand why "this" is not referring to the "<p>" element at all. Any tips and hints are greatly appreciated brothers(Please take it easy on me if I sound dumb, I just started teaching myself JS a couple weeks ago or so, so) Thank you very much guys. <!DOCTYPE html><html><head><script>function myFunction(){ alert(this.id);}</script></head><body><p id = "myPa" onclick="myFunction()">This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.</p></body></html>
  • Create New...