jquery/javascript declare variable from string

Douglas Cottrell

I am looking to loop through all inputs on my page and declare a variable for each using the the id as name. This is what i have tried without success

$('input').each(function(){
    eval( 'var'+$(this).attr('id')+'='+$(this).val());
});
Ankit Tyagi

Try this see if this works :

   $('input').each(function(){
        window[this.id] = this.value;
    });

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Declare object from string

From Dev

How to declare string variable in assembly?

From Dev

Declare a string/word variable in C

From Dev

How to declare string variable in assembly?

From Dev

Declare data from list as a variable

From Dev

Is there a way to declare a Groovy string format in a variable?

From Dev

php Declare a variable by type held in a string

From Dev

how to declare string with math operation as variable in jquery

From Dev

Is it possible to declare a variable with a value for string and a placeholder in python?

From Dev

Declare const String from const String

From Dev

Declare const String from const String

From Dev

declare global namespace variable from TypeScript

From Dev

Must declare Scalar variable - error from parameter

From Dev

How to declare a variable with index from script in Jmeter

From Dev

Can we declare a datatype from a string in java

From Dev

Postgis declare a polygon from a text string

From Dev

How can I declare string reference variable in C#?

From Dev

Is it possible to declare a variable without using "new" like "String" class

From Dev

How to declare a value in a variable where string and char both are present

From Dev

declare multiple variable string for use in IN statement ('i','j')

From Dev

Extract string from variable

From Dev

How can I declare a variable to read from a different table column?

From Dev

Cannot declare a variable with public access in a class from a module

From Dev

How to declare a variable which holds Timestamp value from database?

From Dev

Declare "variable variables" or "dynamic variables" from array values?

From Dev

Declare a Cursor From a Table as Variable (In the Select-Statement)

From Dev

Is it possible to dynamically declare a default namespace from an external variable?

From Dev

Function : Assign value from an attribut to a variable inside DECLARE

From Dev

Is it possible to declare a String from a resource constant for use in a switch case?

Related Related

  1. 1

    Declare object from string

  2. 2

    How to declare string variable in assembly?

  3. 3

    Declare a string/word variable in C

  4. 4

    How to declare string variable in assembly?

  5. 5

    Declare data from list as a variable

  6. 6

    Is there a way to declare a Groovy string format in a variable?

  7. 7

    php Declare a variable by type held in a string

  8. 8

    how to declare string with math operation as variable in jquery

  9. 9

    Is it possible to declare a variable with a value for string and a placeholder in python?

  10. 10

    Declare const String from const String

  11. 11

    Declare const String from const String

  12. 12

    declare global namespace variable from TypeScript

  13. 13

    Must declare Scalar variable - error from parameter

  14. 14

    How to declare a variable with index from script in Jmeter

  15. 15

    Can we declare a datatype from a string in java

  16. 16

    Postgis declare a polygon from a text string

  17. 17

    How can I declare string reference variable in C#?

  18. 18

    Is it possible to declare a variable without using "new" like "String" class

  19. 19

    How to declare a value in a variable where string and char both are present

  20. 20

    declare multiple variable string for use in IN statement ('i','j')

  21. 21

    Extract string from variable

  22. 22

    How can I declare a variable to read from a different table column?

  23. 23

    Cannot declare a variable with public access in a class from a module

  24. 24

    How to declare a variable which holds Timestamp value from database?

  25. 25

    Declare "variable variables" or "dynamic variables" from array values?

  26. 26

    Declare a Cursor From a Table as Variable (In the Select-Statement)

  27. 27

    Is it possible to dynamically declare a default namespace from an external variable?

  28. 28

    Function : Assign value from an attribut to a variable inside DECLARE

  29. 29

    Is it possible to declare a String from a resource constant for use in a switch case?

HotTag

Archive