Page 1 of 1

Buttons not working

Posted: Tue Dec 10, 2013 10:23 am
by Johnny

Hi there

My buttons on app stopped working. It is a new app. can you have a look at it?


Buttons not working

Posted: Tue Dec 10, 2013 10:59 am
by Kateryna Grynko

Hi Johnny,

Are there any console errors (F12)?


Buttons not working

Posted: Tue Dec 10, 2013 11:17 am
by Johnny

Yes, with my second if... but don't know what is wrong
if (localStorage.getitem('nom1').val() != ' ') {
var nom1 = localStorage.getItem('nom1');
var smssave = localStorage.getItem('smssave');
window.location.href='sms:'+nom1.val()+'?body='+smssave.val()+';
}
if (localStorage.getitem('nom2').val() != ' ') {
var nom2 = localStorage.getItem('nom2');
var smssave = localStorage.getItem('smssave');
window.location.href='sms:'+nom2.val()+'?body='+smssave.val()+';
}
if (localStorage.getitem('nom3').val() != ' ') {
var nom3 = localStorage.getItem('nom3');
var smssave = localStorage.getItem('smssave');
window.location.href='sms:'+nom3.val()+'?body='+smssave.val()+';
}
if (localStorage.getitem('nom4').val() != ' ') {
var nom4 = localStorage.getItem('nom4');
var smssave = localStorage.getItem('smssave');
window.location.href='sms:'+nom4.val()+'?body='+smssave.val()+';
}
alert("Send!");


Buttons not working

Posted: Tue Dec 10, 2013 12:30 pm
by Johnny

Changed it to (see below) . But still problem

Code: Select all

 var smssave = localStorage.getItem('smssave'); 

if (localStorage.getitem('nom1') != ' ') {
var nom1 = localStorage.getItem('nom1');
window.location.href='sms:'+nom1.val()+'?body='+smssave.val()+';
}
if (localStorage.getitem('nom2') != ' ') {
var nom2 = localStorage.getItem('nom2');
window.location.href='sms:'+nom2.val()+'?body='+smssave.val()+';
}
if (localStorage.getitem('nom3') != ' ') {
var nom3 = localStorage.getItem('nom3');
window.location.href='sms:'+nom3.val()+'?body='+smssave.val()+';
}
if (localStorage.getitem('nom4') != ' ') {
var nom4 = localStorage.getItem('nom4');
window.location.href='sms:'+nom4.val()+'?body='+smssave.val()+';
}
alert("Send!");


Buttons not working

Posted: Tue Dec 10, 2013 12:55 pm
by Johnny

Made the code easier to read:

var smssave = localStorage.getItem('smssave');
var nomm1 = localStorage.getItem('nom1');
var nomm2 = localStorage.getItem('nom2');
var nomm3 = localStorage.getItem('nom3');
var nomm4 = localStorage.getItem('nom4');

if (nomm1.val() != ' ') {
window.location.href='sms:'+nomm1.val()+'?body='+smssave.val()+';
}
if (nomm2.val() != ' ') {
window.location.href='sms:'+nomm2.val()+'?body='+smssave.val()+';
}
if (nomm3.val() != ' ') {
window.location.href='sms:'+nomm3.val()+'?body='+smssave.val()+';
}
if (nomm4.val() != ' ') {
window.location.href='sms:'+nomm4.val()+'?body='+smssave.val()+';
}
alert("Send!");


Buttons not working

Posted: Tue Dec 10, 2013 2:01 pm
by Johnny

Found my error :) sorry!!

Needed a " ' " on the end


Buttons not working

Posted: Tue Dec 10, 2013 2:48 pm
by Kateryna Grynko

Johnny,

Glad you have it working!