name « String « Javascript Data Type Q&A

Home
Javascript Data Type Q&A
1.Array
2.Clojure
3.date
4.decimal
5.function
6.global
7.loop
8.math
9.number
10.object
11.Regular Expression
12.scope
13.String
14.Var
15.variable
Javascript Data Type Q&A » String » name 

1. How to execute a JavaScript function when I have its name as a string    stackoverflow.com

I have the name of a function in JavaScript as a string, how do I convert that into a function pointer so I can call it later? Depending on the circumstances I ...

2. How to convert variable name to string in JavaScript?    stackoverflow.com

I am new to stackoverflow but I found it pretty helpful several times. Now I have my own question: Is there a way to convert variable names to strings in javascript? ...

3. How do I call a JavaScript function name using a string?    stackoverflow.com

How can I hook up an event to a function name I have defined as a string? I'm using Prototype.js, although this is not Prototype-speficic.

$(inputId).observe('click', formData.fields[x].onclick);
This would result in JavaScript complaining that ...

4. How do I convert a function name into a string    stackoverflow.com

I have a function from an object, lets say Object.MyFunc. I need to send this function name into another function like so: doSomething("Object.MyFunc"); any advise?

5. Is there a way to access a javascript variable using a string that contains the name of the variable?    stackoverflow.com

This way I could have a function that says whatever_way_you_do_this = something. Is this possible? Basically I could tell a function which variable I want to set by giving it a ...

6. fire a function whose name is in a string    stackoverflow.com

I'd like to fire a function. Unfortunately I can't call it directly as the functions' name is provided as a string. Example:

function myFunction() {
   alert('I am myFunction');
}
function anotherFunction() {
  ...

7. JavaScript: Get local variable dynamicly by name string    stackoverflow.com

<script>
//in one script
var someVarName_10 = 20;
</script>
I want to get access to this variable from another script by name of variable. With window object its simple, is it possible with local variable? I ...

8. How can I create variables at run-time based on names pulled from a string?    stackoverflow.com

Hoping someone can assist and hoping this is possible in JavaScript. I basically have the following string in the format: A,B,C:D,E,F What I am trying to achieve is a means of pairing up ...

9. With javascript, is it possible to define a variable's name with another string value?    stackoverflow.com

Example, I have an array called 'categories' with the value ['4','9']. I'm trying to use that value with the name of a previously defined array. I have several arrays defined earlier ...

10. How to get all elements which name starts with some string?    stackoverflow.com

I have an HTML page. I would like to extract all elements which name starts with "q1_". How can I achieve this in JavaScript ? Thanks !

11. Accessing "pseudo-globals" by their name as a string    stackoverflow.com

I am now in the process of removing most globals from my code by enclosing everything in a function, turning the globals into "pseudo globals," that are all accessible from anywhere ...

12. javascript instanceof get type from string name    stackoverflow.com

Let's say I have this (assume the name variable is "receiver"):

if (!(receiver instanceof com.HTMLReceiver)) {
    throw new com.IllegalArgumentException(
        name + " ...

13. What's an easy way to get the url in the current window minus the domain name?    stackoverflow.com

My Javascript ain't so hot, so before I get into some messy string operations, I thought I'd ask: If the current url is: "http://stackoverflow.com/questions/ask" What's a good way to to just get: "/questions/ask" ...

14. Javascript function name as a string in self executing function    stackoverflow.com

I am running a self executing function in javascript to not interfere with any global variables on a page. I have a string with the name of a function I want ...

15. Calling nested function when function name is passed as a string    stackoverflow.com

I'm trying to access a nested function by passing the function name in as a string and then calling it. Eg, see this post

function outer(action){
    window["outer"][action]();

  ...

16. Variable name as a string in Javascript    stackoverflow.com

Is there a way to get a variable name as a string in Javascript? (like NSStringFromSelector in Cocoa) I would like to do like this:

var myFirstName = 'John';
alert(variablesName(myFirstName) + ":" + myFirstName);

--> ...

17. How can I use string argument input as a variable name in javascript?    stackoverflow.com

How can I use string argument input as a part of variable name in a Javascript? I want to do that because it seems to be tedious to define getter and ...

19. pass javascript filename in a string?    stackoverflow.com

I have many JS object literal files in my code. In a JS function

data=data9.webb9[i];
I am accesing it in this way with help of script type="text/javascript" src="webdata"> script in head tag How could I do ...

20. Javascript: The Good Parts Names/Strings railroad diagrams confusing    stackoverflow.com

I started reading Javascript: The Good Parts book and became confused at first pages (7 and 9 if be exact) by the railroad diagrams. There are diagrams for the name and the ...

21. Setting variable by string name in javascript?    stackoverflow.com

//window["Fluent"]["Include"]

function setGlobalVariableByName(name,value)
{
    var indexes = name.split(".");
    var variable = null;
    $.each(indexes, function()
    {
       ...

22. Convert variable name to string in Javascript?    stackoverflow.com

I've seen a few other posts about this on Stack Overflow, but the answer always seems to be to create an object with key / value pairs. This doesn't seem to ...

23. How do I use a string variable as a "name"?    codingforums.com

24. Convert string to variable name    codingforums.com

Say I had a bunch of elements with id names "id1", "id2". "id3" etc. Then say I had a function that adds a click handler such that when you click these elements it gets the id name with this.attributes[1].nodeValue;. Then say I had a bunch of arrays with the same names as the ids var id1 = ["data", false, 45]; var ...

25. string value IS array name    codingforums.com

26. String value to array name    codingforums.com

I have a script which grabs window.location, splits it and then puts part of it into a string. The script also defines a number of arrays. I want to use the string to pull elements out of an associated array (assuming it exists). For example, if the string value is "X" I want to pull elements from the array that is ...

27. Apostrophies in names/strings    forums.digitalpoint.com

I have declared in my JSP a select tag with the following: onChange = "onChangeAction('<%=action%>', '<%=id%>', '<%=key%>', '<%=pageNum%>')" the problem is that the key includes a username so when the user's name is O'Reilly I get this: onChange = "onChangeAction('1', '20', '775954255_O'REILLY', '1')" ...naturally this breaks the entire page since the apostrophie hoses up that string. Anyone have an idea how ...

28. Getting checkbox names into a string    forums.devshed.com

I'm extending a shopping cart for a client to allow customers to place customized coffee orders for delivery. It's been a year or more since I last dealt with Javascript in detail. There are a bunch of flavor shot options in the HTML like so: Apple Blueberry etc.. I already have a script that adds ...

29. From string to radio button group name    forums.devshed.com

I have a form that works like this: you see a list of dog types, and if you have one of those breeds, you click the checkbox next to it. Clicking the checkbox reveals a radio button group. This all works fine, but now I'm doing validation which first checks which checkboxes are checked, and then checks the radio buttons. I'm ...

30. How to use string as Array name?    forums.devshed.com

I agree with jsKid, there doesn't seem to be any need to reference the array by a string containing its name. if you wanted to do this, it would be better to create a container with a string reference for the array, then use the string reference elsewhere... there's a couple ways to do this: Code: JS wierdness