I need to get the value of the selected radio button.Is there any other way to do it?Because event.target.value prints [object Object]

    this.radioButton = event.target.value;
    console.log('event.target.value : '+event.target.value);
    console.log('Selected value : '+this.radioButton);
<input type="radio" name={con} value={item} style="margin-right: 5px;" onclick={getSelectedValues} >

enter image description here

  • What is the type of {item}?
    – David Reed
    Dec 4 '20 at 14:52
  • @DavidReed It is of list type. Dec 4 '20 at 16:52

Use JSON.stringify like this:

console.log('event.target.value : ' + JSON.stringify(event.target.value));

[Object Object] comes when you try to reference an object.

Try this :

var objB = {test:213};

var objB = {test:213};

In your chrome developer console. The first one shows [object Object] and the second one shows 213.

debug it and try to fetch the property of the object. That should give you the correct value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.