Programmatically Set Variable Names By Appending An Id Parameter
Below is an example of my code /// Control vars /// /// Control var ID /// var id=2; /// /// Load Fields by ID /// var name_s_+id=jQuery('#name_c_'+id).val(); /// alert('name_s
Use an object.
var id=2;
var name_s = {};
name_s[id] = jQuery("#name_c_" + id).val();
alert(name_s[id]);
If your IDs are fairly consecutive and start at 0 (or even 1), you can use an array instead:
var name_s = [];
(and the rest is the same).
Post a Comment for "Programmatically Set Variable Names By Appending An Id Parameter"