To get value from parsed json using jquery/javascript -


in below code parsing value using json , set textbox , on onblur event want value of json object.please me .

var reg = json.parse(regularexpression); //regularexpression contains [{"regularexp":"text","exptype":"abc"}] <input type="text" onblur="reg(reg)" />   function reg(val) {         alert('reg');         alert(val);it display[object object]  want values       } 

working example here

reg var , function reg(reg) pass reg function parameter.

so first change var name.

second json.parse(regularexpression) retrun object cant values printing var need reach them here:

var regularexpression = " [{\"regularexp\":\"text\",\"exptype\":\"abc\"}]"; var regobject = json.parse(regularexpression);  function reg(val) {   alert(val[0].regularexp + '\n' + val[0].exptype); } 

and input element should be:

<input type="text" onblur="reg(regobject)" /> 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -