Assign a user input string as a new variable name in javascript -


i have text field in user inputs text. i'd take first word of text , turn global variable name object holding rest of string content. more string content added object later, internal indexing inside object required.

var textinput = $('#inputtext').val(); var splitstring = textinput.split(" "); var firstword = splitstring[0]; 

this stuck. how please create new object string referenced firstword object's reference?

many in advance.

i try this:

globaluserobjects = {};  var textinput = $('#inputtext').val(); var splitstring = textinput.split(" "); var firstword = splitstring[0];  globaluserobjects[firstword] = {};  // later can add stuff  globaluserobjects[firstword]["firstname"] = "john"; globaluserobjects[firstword]["lastname"] = "smith"; 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -