Could someone please tell me what I am doing wrong? I'm not a newbie at programming but I feel like it tonight! Every time I increment the incrementing variable it throws a fit! When add one to it, it behaves fine, but if I try to add one more to it it wants to add 2 more. And then if I try to de-increment it wants to subtract from the original number that it was assigned to.
I've tried:
i++;
i = i+1;
i = i++;
Nothing seems to work. It's got to be a stupid mistake.
Press the buttons to increment and de-increment.
http://michaelreynolds.net/iphone/
here's the code:
var dayNum = 30;
//----------------------------------------------------------------------
$.jQTouch({
icon: 'dailyqoteicon.png',
statusBar: false,
initializeTouch: 'a.touch'
});
//----------------------------------------------------------------------
$(document).ready(function(){
//$(function(){});
$(function(){
$('a.touch').swipe( function(event, info){
//alert("jQTouch swipe event");
//alert(info.direction);
});
});
$(function updateVerse(){
//alert("updateVerse called");
$.ajax({
type: "GET",
dataType: 'JSON',
data: 'day='+ dayNum,
url: 'forward.php',
success: function(data){
var obj = $.parseJSON(data);
$("h2.quote").html("");
$("h3.reference").html("");
$("h2.quote").append(obj.quote);
$("h3.reference").append(obj.reference, " ", obj.version);
//$("span.version").append(obj.version);
//-----------------------------------
// JSON string {"id":"1","quote":"For to me, to live is Christ, and to die is gain","reference":"Philippians 1:21","version":"NKJV"}
},
error: function(request, error){
alert("problem retrieving json data string");
}
});
function addDayNum(){
dayNum = dayNum + 1;
//dayNum = dayNum++;
}
function subDayNum(){
dayNum = dayNum - 1;
//dayNum = dayNum--;
}
$("div#header a.next").tap( function(){
addDayNum();
//dayNum++;// doesn't work at all
//dayNum = dayNum + 1;//doesn't work at all
updateVerse();
//alert(dayNum);
//alert("next clicked");
});
$("div#header a.prev").live('click', function(){
subDayNum();
//dayNum--;//doesn't work at all
//dayNum = dayNum - 1;// doesn't work at all
updateVerse();
//alert(dayNum);
//alert("previous clicked");
});
});
});