Need some help to convert the type of TEXT to NUMBER

hi i need some help for converting the text become number types, i am using wix code to insert my user’s input field to my dataset by the code below, and i am confusing how to let the number type change to number cuz when i using my code let user input insert to dataset it automatically insert in text type but my dataset on that column is setting as number type so it can’t showing and ask me to convert to number type just then the item insert to dataset. So anyone can help me to solve this problem, thanks for helping.

i need the this to become number format
“referral” : $w ( ‘#affiliateId’ ). value ,

import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
import wixData from 'wix-data';

let email = $w('#email').value; 
let password = $w('#password').value; 
let fullName = $w('#fullName').value; 
let bank = $w('#bank').value;
let account = $w('#bankAccount').value;
let bankAccount = bank + " " + account;
let day = $w('#dobDay').value;
let month = $w('#dobMonth').value;
let year = $w('#dobYear').value;
let dob = day + " " + month + " " + year; 
let toInsert = {
 "email" : email ,
 "password" : password ,
 "fullName" : fullName ,
 "contact" : $w('#contact').value ,
 "referral" : $w('#affiliateId').value ,
 "bank" : bank ,
 "bankBranch" : "MALAYSIA LOCAL BANK" ,
 "bankAccount" : account ,
 "vip" :"wix:image://v1/06458d_73166763d2f44d3c8c98446edd957061~mv2.png/_.png#originWidth=343&originHeight=437" ,
 "vipLevel" : "I - STUBBORN BRONZE" ,
 "vipTarget" : "5,000" ,
 "currentVipProgress" : "0.00" ,
 "walletBalance" : "0.00" ,
 "dobDay" : day ,
 "dobMonth" : month ,
 "dobYear" : year ,
 "dateOfBirth" : dob ,
 "country" : $w('#country').value ,
 "language" : $w('#language').value ,
 "creditRatingPoints" : "100" ,
 "creditRatingLevel" : "LEVEL 1" ,
 "userAccount" : bankAccount
};

export function register_click(event) { 
  $w("#errorMessage").collapse();
  $w("#wait").expand(); 
  wixUsers.register(email,password)
 .then(()=>{
    wixData.insert("MemberAccount", toInsert)
 .then( (results) => {
 let item = results; 
      wixLocation.to('/account/myaccount'); 
 })
 .catch( (err) => {
      console.log(err);
      $w("#errorMessage").expand();
      $w("#wait").collapse(); 
 })
 })
 .catch( (err) => {
    console.log(err);
    $w("#errorMessage").expand();
    $w("#wait").collapse(); 
 })
}

thanks

"referral": Number($w('#affiliateId').value),
1 Like

i tried this code, it work but it become 0 in the dataset , i input 1133 it become 0 why ya and my code is not work for some input , can i know is that any problem in my code ? btw thanks you

Your code needs to be inside of the register_click() function in order for your code to be able to access the page elements.

My code is all done for all function, thanks you so much! Appreciate !

1 Like

Thanks you too for helping me alot