2 Replies - 153 Views - Last Post: 07 June 2019 - 08:55 AM

#1 normajean   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 2
  • Joined: 07-June 19

JavaScript code for wix: If statements

Posted 07 June 2019 - 07:53 AM

I'm trying to construct an if statement on wix. I have the below:



if ((Math.ceil((($w("#slider1").value)*1.12)/(($w("#field1").value)*0.15))) === 12 {
    $w("#12wknotificationline1").value = "test"
}

I also created an alternative version:

if ($w("#slider2").min === 12) {
    $w("#12wknotificationline1").value = "test"
} 


Not only do neither of the above work but both stop other elements from working, namely the enabling of slider1.

I'm trying to say: If the minimum value assigned to slider2 is equal to 12, then I want the input field called "12wknotificationline1" to say "test".

How do I construct the if statement?

Is This A Good Question/Topic? 0
  • +

Replies To: JavaScript code for wix: If statements

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15111
  • View blog
  • Posts: 60,456
  • Joined: 12-June 08

Re: JavaScript code for wix: If statements

Posted 07 June 2019 - 08:13 AM

Are there any errors in your console? In your browser hit f12, click console, and try that.

Side note - java is not javascript.
Was This Post Helpful? 0
  • +
  • -

#3 normajean   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 2
  • Joined: 07-June 19

Re: JavaScript code for wix: If statements

Posted 07 June 2019 - 08:55 AM

I figured it out!

i had to move things around a bit as there was some sort of priority problem. Also changed it to

let items = $w("#slider2").min;
if (items === 12) {
$w("#12wknotificationline1").value = "test"

i actually changed it up quite a bit since then. its now an if else statement.

thanks
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1