Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
97
rated 0 times [  102] [ 5]  / answers: 1 / hits: 46102  / 13 Years ago, tue, may 3, 2011, 12:00:00

I'm using two jsp one for searching the records and another for updating the records of the database. Search query will return a json object where it contain all the searched records and I'm generating the rows dynamically to a table for displaying. To update a record, I've kept link in every row.
Here I have to pass the json object to the updating jsp file to load the values. So, I simply passed the json object. But, I cannot process the json object. Help me out. Thanks. Please Find the code below:



function retrievesrchrec(){                 
var result = xmlHttp.responseText;
if(result.length>1){
var dbRecords = JSON.parse(result);
if(dbRecords)
{
while(dbRecords[index])
{
dbRecord= dbRecords[index];
var rbutton = document.createElement(input);
rbutton.type = a;
rbutton.href = function(){
javascript:loadModify(jsonobj);
};

}
}
}
}
function loadmodify(jsonobj){
alert(jsonobj);
}

More From » json

 Answers
23

A JSON object is not more than a regular javascript object. It should work if you pass it as a parameter to a function. The problem is somewhere else.



Try this version:



function retrievesrchrec(){                 
var result = xmlHttp.responseText;
if(result.length>1){
var dbRecords = JSON.parse(result);
if(dbRecords)
{
var index=0;
while(dbRecords[index])
{
dbRecord= dbRecords[index];
var rbutton = document.createElement(A);
rbutton.href = loadModify(dbRecord);
index++;
}
}
}
}
function loadModify(jsonobj){
alert(JSON.stringify(jsonobj));
alert(jsonobj.EnvLabel);
return http://www.example.com;
}

[#92438] Saturday, April 30, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kylanalis

Total Points: 438
Total Questions: 85
Total Answers: 102

Location: Barbados
Member since Sun, Nov 27, 2022
1 Year ago
kylanalis questions
Sat, Oct 2, 21, 00:00, 3 Years ago
Tue, Oct 13, 20, 00:00, 4 Years ago
Thu, Feb 13, 20, 00:00, 4 Years ago
Tue, Jan 7, 20, 00:00, 4 Years ago
;