Skip to content
Advertisement

How to combine each select tag’s data

I’m creating a sign-up page in vue3 now and trying to pass the value of birthDate. The date of birth consists of three select tags and each tag has a year, month, and day as an option. I want to combine the values of each select tags into birthDate. and need to deliver the value of the birthDate through ‘axios post’ toward the backend (form like (20150516)).

this is Join.vue

JavaScript

and this is join.js

JavaScript

Advertisement

Answer

You could play around with substrings to get/set the first 4 chars for year, 2 for month and 2 for days of the birthDate string.

But if it was me, I would keep the year, month and day separate in the store and combine when calling the api:

axios.post(‘http://??.???.???.???:????/api/signup’, { …state.Userinfo, birthDate: `${state.birthYear}${state.birthMonth}${state.birthDay}`, });

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