# Javascript help

Hello guys, again,

I have a question regarding the toolbox plugin to run javascript in workflows. I have a form where my employees will fill out what time they started and what time they ended a job. Example from 9am to 1pm. On my old website (wordpress) i had a javascript script that would then take those times and i made a math equation to calculate the time they worked. The time in/out fields are 3 seperate dropdowns, one for hour, one for minute and one for AM/PM. This is what worked for me on wordpress. Then the equation would do the math to figure out how many minutes apart each time is. How can i use this for bubble.is?

How can i write into an input using javascript to save this calculation as part of a thing. and below i posted a snippet of the code, just to make sure this will work with bubble.is?

\$hourin = \$_POST[‘item_meta’][597];
\$hourout = \$_POST[‘item_meta’][600];
\$minin = \$_POST[‘item_meta’][598];
\$minout = \$_POST[‘item_meta’][601];
\$ampmin = \$_POST[‘item_meta’][599];
\$ampmout = \$_POST[‘item_meta’][602];
\$break = \$_POST[‘item_meta’][567];

if ((\$ampmin==AM) and (\$ampmout==PM)) { //converting time difference if start - end is AM - PM
\$t1 = (\$hourin * 60) + \$minin;
if (\$hourout==12){
\$t2 = (\$hourout * 60) + \$minout;
} else {
\$t2 = ((\$hourout + 12) * 60) + \$minout;}
\$t3 = \$t2 - \$t1;
\$t4 = floor(\$t3 / 60);
\$t5 = \$t3 - (\$t4 * 60);
}

the \$_POST[‘item_meta’][597]; is how i would get the user input for the dropdowns on my other form program (formidable forms). im assuming with bubble i can use something like \$hourin = start hour’s value; using the dynamic datas.

Its ok. i was able to do a workaround to calculate time used between two different times. using a series of inputs and math expressions from the toolbox plugin. Thanks

This topic was automatically closed after 70 days. New replies are no longer allowed.