Skip to content
Advertisement

Radio Button Display as current Value

I have a radio button that act as status selector for company record. Problem is when edit record. i want radio button in editdialog preselect according to current status of record.

current code

JavaScript

I’ve tried a solution as in this link and it still don’t work as intend.

JavaScript

this time it warn me that Active and inactive property or method is not define.

pls advise

ps. I’m pretty new to coding and vue (2week)

Update solved

JavaScript

Advertisement

Answer

Your second example is mostly correct. However, the :value binding expects an expression, and in this case it’s true that the binding cannot find a variable/property named Active or Inactive on the model. Instead, you could wrap the value bindings in quotes (because 'Active' in JavaScript is an expression which evaluates as a string literal):

JavaScript

Note the quotes around Active.

Alternatively, you can use the literal modifier, which tells the value binding to interpret the given value as a literal rather than an expression:

JavaScript

Whichever approach you choose, apply the same to the Inactive radio button element.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement