Pls help result not storing in dataset/collection

I created two inputs box #a and #b and its operation is adding and its result is stored in input box #c
I connected all of its value to dataset/collection But After Submitting the result value (#c ) is not saving in the dataset how can I save it. both user-entered #a #b value has stored but the result #c is not stored in dataset

In addition to storing the value in input box #C , you also need to use the dataset setFieldValue() function before submit.

Yes I Used SetFieldValue() but It does’nt Works Can you Help me With example code
export function button9_click ( event ) {
$w ( “#dataset3” ). setFieldValue ( “nickname” , $w ( ‘#input10’ ). value );

    $w ( "#dataset3" ). setFieldValue ( "first" ,  $w ( '#input12' ). value ); 

    $w ( "#dataset3" ). setFieldValue ( "last" ,  $w ( '#input5' ). value ); 

    $w ( "#dataset3" ). setFieldValue ( "resul" ,  $w ( '#input6' ). value ); 

}

This Only Works in preview Mode

@sougandhr Does it work or not? What works in Preview?

You do not need to set all of the fields using setFieldValue(). Only the field that are setting with code. As you stated: “both user-entered #a #b value has stored”.

What code do you use to get a result? Where do you set it to input field #c?

Please share your code in a code block so we can see what you are doing.

@yisrael-wix First of all, i connected these three input boxes To the database without code then both user-entered input box works but the third input box ‘result’ value is not storing in the collection(the value of the third input box is a calculation on first and second box) so i use setFieldValue()then it works when I tested in preview mode but when it is live it doesn’t works

import wixUsers from ‘wix-users’ ;
import wixData from ‘wix-data’ ;

$w . onReady ( function ()
{
wixData . query ( “Members/PrivateMembersData” )
. eq ( “_id” , wixUsers . currentUser . id )
. find ()
. then ( ( results ) => {
$w ( ‘#input10’ ). value = results . items [ 0 ]. nickname ;
});

});

export function button9_click ( event )
{
$w ( “#dataset3” ). setFieldValue ( “nickname” , $w ( ‘#input10’ ). value );
$w ( “#dataset3” ). setFieldValue ( “first” , $w ( ‘#input12’ ). value );
$w ( “#dataset3” ). setFieldValue ( “last” , $w ( ‘#input5’ ). value );
$w ( “#dataset3” ). setFieldValue ( “result” , $w ( ‘#input6’ ). value );
}

export function input5_input ( event )
{
var price = parseFloat ( $w ( ‘#input12’ ). value )
var prices = parseFloat ( $w ( ‘#input5’ ). value )
var total = price * prices
$w ( ‘#input6’ ). value = ‘Rs’ + total + ‘’

}

Its not working on live, pls help if any modification needed

What you should do is right after setting the input element, set the field:

$w('#input10').value = results.items[0].nickname;
$w("#dataset3").setFieldValue("nickname", results.items[0].nickname);

and

$w('#input6').value='Rs'+ total;
$w("#dataset3").setFieldValue("result", total);

When you run in Preview, you are already logged in so that’s why it works for you.

If you want it to run in Live, the user needs to be logged in.

ThankYou @yisrael-wix For Your Help , It Works

Thankyou For Giving Your Time