John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

comparing two values...

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?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

comparing two values...

Do you have a ; after the statements?

John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

comparing two values...

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

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

comparing two values...

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.

John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

comparing two values...

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.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

comparing two values...

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

Return to “Issues”