Skip to content
Advertisement

Data Transfer Between Options to Same Value and Value

There are two different select elements. These have equal value and text. There is also a radio button. If the button with the same id is selected, I want to pass the value of the first option to the second. I wrote a jQuery code for this. However, instead of transferring, it creates a new text. I want the same value to be selected in the second one. Although I searched for examples to solve the problem, I did not know exactly how to search. Therefore, I could not come to a conclusion.

First option

JavaScript

Second option

JavaScript

Radio Button

JavaScript

jQuery Code

JavaScript

Advertisement

Answer

Consider the following example.

JavaScript
JavaScript

Your script changes the text but does not adjust which option is selected. Using the proper Selector, you can then re-assign which Option is selected.

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