Page 1 of 1

comparing two values...

Posted: Mon Jul 22, 2013 5:40 pm
by John Herdean

Hi, Im trying to compare 2 values that are inside local storage. When i compare the same values it goes to 'checkout' - but when i compare two different values I get an error as follows:

Image

what its supposed to do when it compares two different values is go to a popup "checkout_pin_wrong"

here is the JS i wrote:

------------------------------------------------------------------------------------

var a = localStorage.getItem('pin_num')
var b = localStorage.getItem('pin_num_confirm')

if (a == b) {
Appery.navigateTo('checkout', {
transition: 'flip',
reverse: false
});
}
else {
$.mobile.changePage("checkout_pin_wrong", {transition: "pop"});
}

-------------------------------------------------------------------------------

Supposedly theres a syntax error... Where would that be?


comparing two values...

Posted: Mon Jul 22, 2013 6:04 pm
by maxkatz

Do you have a ; after the statements?


comparing two values...

Posted: Mon Jul 22, 2013 6:50 pm
by John Herdean

well, you can see my exact code in my original post and where they are...


comparing two values...

Posted: Mon Jul 22, 2013 6:52 pm
by maxkatz

You should check these statements:

var a = localStorage.getItem('pin_num')
var b = localStorage.getItem('pin_num_confirm')

You should debug your code. User written JavaScript code usually falls outside the scope of our support.


comparing two values...

Posted: Tue Jul 23, 2013 6:21 pm
by John Herdean

thats strange, I added a ; after those 2 statements and it worked. But what I dont understand is why in the majority of cases Im dealing with is that im not using ; after every statement...

Anyways, I appreciate you pointing that out to me.


comparing two values...

Posted: Tue Jul 23, 2013 6:38 pm
by Maryna Brodina

Hi! It's better to use ; as on code generation two lines can be merged to the one, this can cause some problem.