I am using a JSON object something like this {"expiry_year":"15","number":"411111","month":"12","cvn":"456"}
Now on some callback I am getting this value. My requirement is to put these values in a from by using MAP so in future if some one change DOM id it won’t affect the page.
To achieve this I am trying like this
var domWithValueMap = {
"number" : "number",
"cnv" : "cnv",
"month" : "expiry_month",
"expiry_year" : "expiry_year"
}
In above hash
var domWithValueMap = {
"keys of json obg" : "id of DOM",
}
and so on..
My div id’s are : number,expiry_year,month and cvn.
Then after I was trying to match whether the keys are exists or not using this
domWithValueMap.hasOwnProperty(key);
After this I gets confused how to proceed. Please help me to achieve this.
This should do the trick:
A little longer, with comments: