Dropdown with specific times

Hi all. I have a user input form that at the moment the user selects a future time through a date picker and time picker. What I want to do is simplify this into a dropdown with set minutes/hours in the future. I’ve started the code for the dropdown and it saves into the datetime field in my collection but it’s saving as a text element rather the datetime. I know I need to convert the value field of the dropdown to datetime but I don’t have lots of code experience and just can’t work out how to do this. I’ve tried to research this but can’t seem to find anything. Below is a copy of the dropdown code so you can see what I have at the moment. Can someone please help with the missing bit of code!

$w.onReady( function () {
$w(“#dropdown2”).placeholder = “Time”;
$w(“#dropdown2”).options = [
{“label”: “1 minute”, “value”: “00:30”}, //30 minutes from now
{“label”: “5 Minutes”, “value”: “00:45”}, //45 minute from now
{“label”: “10 Minutes”, “value”: “01:00”} //1 hour from now
];
})

This is how I save it to my collection:

$w.onReady( function () {
$w(“#button2”).onClick((event) => {
let toSave = {
“dateTimer”: $w(‘#dropdown2’).value
}
wixData.save(“Timedout”, toSave)
.then(() => {
wixLocation.to(“/all”);
})
})
})
})

What about:

let selectedTime = $w("#dropdown").value.split(":");
selectedTime[0] = Number(selectedTime[0])  * 3600000;//converts hours to milliseconds
selectedTime[1] = Number(selectedTime[1])  * 60000;//converts minutes to ms
let finalTime = new Date(new Date().getTime() + selectedTime[0] + selectedTime[1]);
//then save finalTime

I’ve added the code but it’s not working and the submit button #button2 isn’t doing anything at all not even redirecting to the all page. This is how I’ve added the code

$w.onReady( function () {
$w(“#dropdown2”).placeholder = “Time”;
$w(“#dropdown2”).options = [
{“label”: “1 minute”, “value”: “00:30”},
{“label”: “5 Minutes”, “value”: “00:45”},
{“label”: “10 Minutes”, “value”: “01:00”}
];
})
let selectedTime = $w(“#dropdown2”).value.split(“:”);
selectedTime[0] = Number(selectedTime[0]) * 3600000;//converts hours to milliseconds
selectedTime[1] = Number(selectedTime[1]) * 60000;//converts minutes to ms
let finalTime = new Date( new Date().getTime() + selectedTime[0] + selectedTime[1]);

$w.onReady( function () { $w(" #button2 “).onClick((event) => {
let toSave = { “dateTimer”: $w(’ #dropdown2 ').value }
wixData.save(“Timedout”, toSave)
.then(() => {
wixLocation.to(”/all");
})
})
})
})

@ibateman37 you should put my code inside the $w(“#button2”).onClick(), before the let toSave .

Also in the toSave itself, don’t use dropdown2.value, but finalTime

@jonatandor35 I think my copy and paste went a bit weird there! I had got finalTime in my code and it works now I’ve moved the code to where you siad! Another drink I owe you!