I have the following code:
var address;
getAddress(0,0);
function getAddress(latlng)
{
if (latlng != null)
{
geocoder.getLocations(latlng,
function(addresses)
{
...
|
I have a problem going on here and without going into a lot of detail and confusing everyone, let me just ask the simple question.
Here are two functions. I need to ... |
What I need help with:
My page shall take user input text, then show what was entered on the page (no alert) and open a new window on click if a match ... |
please have a look at the following code. When the value of i == 0 the alert 1 prints variable values as per logic. But if I try to print values ... |
One aspect of javascript that it's hard to find information on is casing practices. By casing practices, I mean what casing style (ie. camel-case, pascal-case, etc) should be used for ... |
In a situation like the code below how would you go about accessing a variable value that is in an anonymous function? I would like to return the bool value of ... |
Does anyone know how can I replace the passing variable in html with Javascript?
Example:
If I have a code as below:
<table width="150" border="0" cellspacing="0" cellpadding="2" id="productBox">
<tr>
<td valign="top" height="19" ...
|
|
My Firefox extension must do the following:
- Save the address of the current page
- Open a new page
- Put the address into the content of the new page if a button is pressed
The problem ... |
Is there any difference between
function MyFunc() {
// code...
}
and
var MyFunc = function() {
// code...
};
in JavaScript?
|
If only string is allowed to pass into function process(), what should we do inside the function process() to access the array value. Eval is one of the method, but its ... |
I have a variable named age and a function named AGE. Ignore the problem I am having with JScript beign case insensitive at the moment, i.e. age(dob) and AGE(dob) both ... |
Suppose I have a long javascript function such as
function test() {
var x;
var a;
...
...
...
|
First off, here's my code:
var variable1 = 10;
function f1 (){
alert(variable1);
}
//When button is pressed, call function
$("#button").click(f1);
Why can I not access variable1 inside the function?
Many thanks and ... |
function foo(bar) {
// ...
}
and
foo = function(bar) {
// ...
};
What is the benefit of one versus the other? The main benefit I see in ... |
I have the following functions:
// NATION
var x, y, z;
function flag(nation,area)
{
x = nation;
this.nation=nation;
var el=document.getElementById("desc");
el.innerHTML='The region you have selected is <b>'+area+'</b>';
document.getElementById("flag").innerHTML='<img src="images/flags/'+nation+'.jpg">';
}
// SERVICE
function output(service)
{
y = service;
this.service=service;
var el=document.getElementById("service-desc");
el.innerHTML='You have selected a <b>'+service+'</b> service.';
document.getElementById("clock").innerHTML='<img src="images/clock-'+service+'.png">';
}
And ... |
I want to know if there exists a tool to help in reversing a compressed javascript that has obscure variable names. I am not looking for a pretty-printing beautifier, but for ... |
Hey guys need some help in adding a view cart button but I'm stuck not sure how to code it. any help?
The way I have coded it is that when a ... |
I'm sorting array:
myArray.sort(comparators.some_comparator);
and I have several comparator to choose from:
comparators = {
asc_firstname_comparator : function(o1, o2){
...
}
desc_firstname_comparator : function(o1, o2){
...
|
I have a function which takes a callback function. How can I set the 'this' variable of the callback function?
eg.
function(fn){
//do some stuff
fn(); ...
|
I'm writing some Javascript code and I need to keep track of a global state. The state is only ever changed by a single function, but it needs to be widely ... |
Say I have some context where variables are set and a ?-function is called which uses them directly:
function outerContext(){
...
var data = ...; // ...
|
I have a number of links, that when clicked on, passes a variable thru to another portion of the page.
Yet, for some reason, I can’t figure it out! What am ... |
I have the following code in Javascript:
jQuery(document).ready(function(){
var actions = new Object();
var actions;
actions[0] = 'create';
actions[1] = ...
|
I have a function that I want to pass an argument to, however I want it to default to 0.
Is it possible todo it similarly to PHP, like:
function byMonth(export=0) {
Many thanks
... |
Here is my dilemma.
I've got this section of code:
var list_of_numbers = new Array();
function AddToArray(func)
{
// Add to the *beginning* of the array
// essentially reversing ...
|
In PHP we can specify default value of variable in function like:
function myFunction(myDefaultVariable, myOtherVariable, myCheckVariable = "basic"){
// so yeah, myDefaultVariable is required always,
// ...
|
i hope this question is not too simple, but i have no idea :(
How can i start a function with a var in the function name?
For example ...
my functions
function at_26();
function at_21();
function ...
|
Possible Duplicate:
Javascript: var functionName = function() {} vs function functionName() {}
Every now and again I see examples of JS code where an anonymous function ... |
I have a variable in a function that I want to be accessible by other functions. How would you do that?
|
I want to use a function's variable value to build a variable in the function.
Here's what I got so far:
function foo(1a, 1b) {
var money = document.myform.1b;
}
So basically, if I pass ... |
i made this using mootools:
$("fox").addEvent("click", function(){
alert("clicked");
});
and the html:
<p id="fox">A</p>
now if i try it here http://jsfiddle.net/5uJ54/3/ , it works but if i try it in a browser and thats all ... |
As a followup to this question still trying to grok Javascript function anomalies, can someone explain why the following code works?
My text (Javascript Patterns) states:
If you create ... |
Let's say I have a function and one of the parameters is for the name of the target variable.. Would it be possible for me to send a variable to the ... |
I've am trying to make a canvas animation:
var context;
var meter;
var pin;
function init() {
var meter = new Image();
var pin = new Image();
...
|
Possible Duplicate:
Are there any good Javascript code coverage tools?
is there a firefox addon or something that scans a web document and tells me what ... |
Here's the problem, document.onkeydown = checkkeycode
I'm passing two variable to checkeycode e which is storing the event and hence keycode and the array circle which I want to update with variable ... |
I am still new to javascript, and I am trying to get a function to return a variable using html & javascript. Basically the function should just return whichever radio ... |
how can i access a variable that was intialsed in a function, but the main.name is giving me a null value, i know the value is initliased in the function, or ... |
In the code below, if result is set to one, the code returns a number 1024 (2 to the power of 10). If result is set to 2, the code returns ... |
I create a context-menu from an array like this:
var menu1 = [
{
'OPTION1':function(menuItem,menu) {
// ...
|
A somewhat basic question here. I can see what is going on but I can't really understand why it would work this way.
a = false;
var k = function() {
...
|
I am trying to pull a variable that is captured from a form element in to a function chain. The variable value needs to act as a function name. Example:
<form name="myform">
...
|
I have seen recent code examples placing functions inside variables and then calling the functions like normal.
As in:
var myFunctionName = function() {
Code Here...
}
myFunctionName();
I'm sure there are a ... |
Is there a way in JavaScript to have something like an event that listens to changes in a variable? so when its value is modified the event triggers and then I ... |
I'm pretty much a complete noob when it comes to JS and I'm having the hardest time with this.
I'm working with Titanium Appcelerator and I need to use the lon/lat ... |
var johnson = button.addEventListener('click', function() {
});
In what ways i can use this variable name. can i call the johnson as a function somewhere?
|
var value;
addEventListener('GetPatientSearchValues', function() {
var value= 20;
FunctionName();
});
Function FunctionName();
{
value = value + 1;
}
My problem is i need to recieve the value 20 and i need to pass it to FunctioName. ... |
setup: function (baseUrl, devModeCheck) {
where devModeCheck is a function that will be called.
Is there any commonly-used naming convention in javascript that makes this intention obvious?
devModeCheckFunc and fDevModeCheck both seem kind-of horrible.
... |
anybody knows a program or script or tool that renames functions and variables for a list of Javascript files?
A program like http://javascript-source.com/index.html just open source or freeware?
Thank you very ... |
window.onload = raknaUtMedelvarde;
function raknaUtMedelvarde(){
var tabell = document.getElementById("temperaturtabell");
var rader = tabell.getElementsByTagName("tr");
for (var i = 0; i < rader.length; i++){
...
|
I need to loop over the properties of a javascript object. How can I tell if a property is a function or just a value?
var model =
{
...
|
I'm trying to return variables as true or false via a function. I want to do it this way so I can call ajax only once, and receive both variables back ... |
Suppose I have any variable, which is defined as follows:
var a = function(){/* Statements */};
I want a function which checks if the type of the variable is function-like. i.e. :
function(v){if(v is ...
|
Possible Duplicate:
How to know variables from different…“namespaces” ?
I have a webphone integrated into our webpage, and when a call comes in, a javascript function ... |
I cannot get this to work:
function formvalidation()
{
var SiteNum= document.getElementsByName("sitesinput")[0].value;
var i=1;
while (i<=SiteNum)
{
...
|
Im trying to set up a variable and pass it constructor function essentailly like an anonymous type in c# but javascript doesnt seem to like it...
var aPerson = function Person(){
};
$(document).ready(function(){
...
|
I'm fairly new to JS but am familiar with AS2(Flash). In Flash I can put variables inside movieclips (objects) and have attempted to do something similar here with dropdowns:
http://tamalecreative.com.au/korban/scripts/dropdown.js
specifically:
...
|
I am trying to reduce the repetition in my code but not having any luck. I reduced the code down to its simplest functionality to try and get it to work.
The ... |
I have a code like this;
<script type="text/javascript">
var ID= document.getElementById('customfield_10033');
var IDNumber= document.getElementById('customfield_10033').value;
ID.onblur=function(IDNumber)
{
if ((IDNumber!="") && (IDNumber.length!=11)){
alert("Your ID number should 11 ...
|
How can I in the easiest way access an instance variable inside a function?
function MyObject(){
//Instance variables
this.handler;
//Methods
...
|
I've been working on a javascript library, and I have a lot of redundant checks like this:
if(typeof foo !== "undefined" && foo !== null)
So, I wanted to create a function that ... |
I have two javascript methods ( imports, and namespace)
imports take a string argument( eg. imports("com.x.y.MyClass")) and based on string it create a relative path and append it to head tag as ... |
This may seem simple to some but I am less experienced with JavaScript. I have two functions. One is called when my upload begins. The next is called when my upload ... |
i am trying to understand what is the best practice for defining and organizing my js viewmodels with knockout. I am not js genius so...
Ok so in many of the examples ... |
I'm writing code for a blackjack game and have run into some problems. I have written two functions: one for the initial deal and one for each consecutive hit. this is ... |
i got in one scope this function:
AjaxState.prototype.run_on_finish = function(callback){
if (this.isRunning()){
setTimeout('AjaxState.obj().run_on_finish('+callback+')', 250);
}else{
...
|
Is it possible to load multiple scripts with same variables/functions in JS, without overriding the old value of the variable. For example to create an own scope/sandbox or object for each ... |
this question is pretty straightforward. I want to be able to detect whether a variable is false, and set it to true, commonly known as toggle.
Here is it:
var hello = false ...
|
how can i use variable of without functions:
sample:
var name = 'Jim';
function is_name()
{
alert(name);
}
is_name() //alert : Jim
tanX
|
Consider these two blocks:
Block A
obj = {
a: 1,
b: 2,
c: 3,
f: function() {
...
|
I'm trying to add 10 over and over for every invocation of d. It stays 20 every time, why?
function d() {
var c = [10];
...
|
I have been trying to write a constructor function that would make an object chock full of complex methods. These methods process variables of their parents as-well as call on sibling ... |
I use CodeMirror in my project and i don´t know how to do something like this:
var formname = $.cookie("formnamecookie");
var formcode = formname.getValue();
Is this possible?
I hope you understand ... |
I want to get Value from CodeMirror textarea whose name I have in Cookie. How can I do this?
I tried:
var formname = $.cookie("formname");
var formcode = formname.getValue();
Firebug ... |
element.onmouseover = function onmouseover(event){ this.src=oldLinkImageOver; };
the variable oldLinkImageOver is a variable holding the string "images/image.png", but alert(element.onmouseover); on this will come out as oldLinkImageOver rather than what it references.
Is ... |
windows.onload=function(){
...somecode...
var scene = new THREE.Scene();
...somecode...
var i;
var j;
for ...
|
I've got a function that I've written that populates a URL (that contains an image) based on the browser language. This subsequent URL is then written to a variable. All the ... |
I'm using the following function but it does work, can someone please point out what is wrong.
The vb variable is generated from a database query.
window.onload function PostCodeChecker() {
if (<%= sPostalCode %> ...
|
This is an issue with Javascript executing linearly on a single thread.
using
setTimeout(function(){},time);
is evaluated and executing the function() immediately.
I am looking for a method to execute function() in x ... |
In the code exercise at Codecademy[1], it asks you to cube a variable and I can easily do that using:
// Accepts a number x as input and returns its square
function square(x) ...
|
I have a project that has a CHtmlView. This html view displays user customizable html files. However from my program I want to supply variables (strings mainly) and/or provide functions that can be called from the javascript of the hosted pages. The idea is that the javascript can then use those variables to dynamically generate the content the users want to ... |
Using variable to control two functions: having problems! Code: JS: Image Slider |