In the model i have like,
def question_hash_string
@question_hash_string || '{}'
end
def question_hash
ActiveSupport::JSON.decode question_hash_string
end
In the Javascript,
var question_hash_element = document.getElementById('enr_rds_batch_update_question_hash_string');
var question_hash = JSON.parse(question_hash_element.value);
question_hash[batch_question_id] = (batch_answer_id || batch_rdsap_answer || batch_answer_checkbox);
question_hash_element.value = JSON.stringify(question_hash);
It would give the values like "{"16":"3","28":false}"
I want to add another value with the answer like the following,
question_hash[batch_question_id] = ((batch_answer_id || batch_rdsap_answer || batch_answer_checkbox) && (build_id));
"{"16":"3","28":false:"2", "3":"55":"54"}" and so on. I need to add another column with the existing record with ‘:’.
Adding a key/value pair to a javascript object :