Onready Function

Hello,
i think that there was an update on the code and now my code inside the onready function is not working.
I want to set the multiple selection input to a specific value when the page load.
I want to set the multiple selection input SET to value 1.
This is the code:

$w ( ‘#set’ ). value =( 1 ). toFixed ( 2 ). toString ();
$w ( ‘#rep’ ). value =( 5 ). toFixed ( 2 ). toString ();
$w ( ‘#load’ ). value =( 70 ). toFixed ( 2 ). toString ();

$w ( '#set2' ). value  =( 1 ). toFixed ( 2 ). toString (); 
$w ( '#rep2' ). value  =( 4 ). toFixed ( 2 ). toString (); 
$w ( '#load2' ). value  =( 75 ). toFixed ( 2 ). toString (); 

$w ( '#set3' ). value  =( 2 ). toFixed ( 2 ). toString (); 
$w ( '#rep3' ). value  =( 3 ). toFixed ( 2 ). toString (); 
$w ( '#load3' ). value  =( 80 ). toFixed ( 2 ). toString (); 

$w ( '#set4' ). value  =( 2 ). toFixed ( 2 ). toString (); 
$w ( '#rep4' ). value  =( 2 ). toFixed ( 2 ). toString (); 
$w ( '#load4' ). value  =( 85 ). toFixed ( 2 ). toString (); 

$w ( '#set5' ). value  =( 2 ). toFixed ( 2 ). toString (); 
$w ( '#rep5' ). value  =( 1 ). toFixed ( 2 ). toString (); 
$w ( '#load5' ). value  =( 90 ). toFixed ( 2 ). toString (); 

I hope somebody can help me.
Thank you

I don’t see a problem with your code. You do not need the .toString() since .toFixed() makes it a string, but this extra method call shouldn’t be a problem.

I tryied this method and is working

export function reset ( event ) {

$w ( ' [#set](https://www.wix.com/velo/forum/search/~num~set) ' ). value  =  1 ; 

}

but the automatic corretion give me error that it’s impossible to assign number value to a type string :

Just try to think the logical way. What does the ERROR wants to tell you?

  1. You have a —> NUMBER!
  2. But expected is a —> STRING!

Conclusion? —> You will need to converst from → NUMBER → to → STRING.

How to do it?

var myNumber = 100
var myString = String(myNumber)

…or…

var myString = myNumber.toString()

This should fix your problem.

Do you mean a i should convert my number variabile into a string variable and then send it to the multiple selection input?
Not send it directly with a conversion?

Some coding tips 4-you.

If you are using elements in your project like…
-buttons
-images
-stripes
-boxes
…and so on…

Do yourself a favour and give them plausible IDs!
For example —> which element is in your project → “#set” ???
Is it a button?
Is it a box?
Is it a textfield?
Is it something else?

You as project-creator, you will be able to read your code faster than, someone-extern who you are asking for help, because nobody can see your project and it’s SETUP.

CONCLUSION:
You always should give good-readable IDs to every of your elements.

Example:
ID for a BUTTON —> “#btnFacebook” ← do you have any sugestions, what this element could be?

…or… —> “#txtFieldSet” <— ??? Still plausible enough?

The more your CODE will growing, the more difficult it will be to read your own CODE!

So if —> ‘#set’ <— is a TEXTFIELD or a INPUTFIELD it surely will expect a ---------------->STRING as value.

$w ( ’ #set ’ ). value = 1 ; —> VALUE = NUMBER
$w ( ’ #set ’ ). value = “1” ; —> VALUE = STRING

Ok this was helpful…
I have an other basic question:
How can i Add some additional space insidie my string into a textbox ?
Ex.
I need to write
Back squat 100
But i only get the result:
Back squat 100

You can do it in many ways like:

"Back Squat" + "  " + "100" //Just concatenating string
exerciseName + "  " + variableName //Using concatenating variables in your strings
`Back Squat  100` //Using back ticks or template strings, is the way to go.
`${exerciseName} ${variableName}` //This would be the best way, you can insert many spaces between the variables in this template string