Insert Datas Into Mysql(sequelize) Using Javascript(nodejs) Based On Radio Button Value
I have this below json object { 'phoneno': [ { 'field1': 'Mohamed', 'field2': '123456789', 'field3': 'Sameer' }, { 'field1': 'Ganesh
Solution 1:
It will be helpful to you, In your data, you should mention which is column selected for example field2
is selected means you should append that to your JSON data.
In your case, I have added new key to find which is column "selected_radio":"field2"
like this you should do the same on your front end
and here is the angular part of change your JSON data
var data={
"phoneno": [
{
"field1": "Mohamed",
"field2": "123456789",
"field3": "Sameer"
},
{
"field1": "Ganesh",
"field2": "987654321",
"field3": "Pandiyan"
}
],
"sender": "ifelse",
"message": "test",
"selected_radio":"field2"
};
var new_data=[];
_.each(data.phoneno,function(obj){
new_data.push({"phoneno":obj[data.selected_radio],"sender":data.sender,"message":data.message});
})
console.log(new_data);
<scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script>
Post a Comment for "Insert Datas Into Mysql(sequelize) Using Javascript(nodejs) Based On Radio Button Value"