variable being overwritten by default?

Hello experts, in the code sample below I've set a default folderID of 1.  My "folderID click function" is successfull passing the selected folderID to "inboxresults.cfm".  

However, my "next" and "previous" click functions always pass the default folderID value of 1 (and never a newly selected value).  

Can you please help me understand how to update the default value  (I thought I was by setting "var folderID = $(this).attr('data-id'); " in my ".folderID" click function.

As always, your time is appreciated.
K
<script type="text/javascript">
$.ajaxSetup ({
    // Disable caching of AJAX responses
    cache: false
});

var folderID = 1

	



$(function() {
		
	function loadMessages() {	  
 	var myInbox = "/test/inboxResults.cfm?folderID="+folderID;
	$("#messageList").load(myInbox)
	  var myFolders = "/test/folders.cfm";
	$("#mainFolders").load(myFolders)  
	}   
	
	loadMessages();
	
	$("#next").click(function() {
		var myInbox = "/test/inboxResults.cfm?folderID="+folderID;
		myInbox+="&startRow="+nextstart
		$.get(myInbox,function(data){
		$("#messageList").html(data);
	  });
	})
	
	
	$("#prev").click(function() {
		var folderID = $(this).attr('data-id'); 							  
		var myInbox = "/test/inboxResults.cfm?folderID="+folderID;
		myInbox+="&startRow="+prevstart
		$.get(myInbox,function(data){
		$("#messageList").html(data);
	  });
	})
	

	$(".folderID").click(function() {
 		var folderID = $(this).attr('data-id'); 				  
		var myInbox = "/test/inboxResults.cfm?folderID="+folderID;
		$.get(myInbox,function(data){
		$("#messageList").html(data);
	  });
	})	
})


var prevstart = 1
var nextstart = 1

function showPrev(newprevstart){
	prevstart = newprevstart
	$("#prev").show()
}

function hidePrev(){
	$("#prev").hide()
}

function showNext(newnextstart){
	nextstart = newnextstart
	$("#next").show()
}

function hideNext(){
	$("#next").hide()
}
</script>

Open in new window

whaleykAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HainKurtSr. System AnalystCommented:
try modifying line 44 as:


             var folderID = $(this).attr('data-id');
-->
             folderID = $(this).attr('data-id');
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HainKurtSr. System AnalystCommented:
also you can remove line 34

var folderID = $(this).attr('data-id');

0
HainKurtSr. System AnalystCommented:
but where do you change the values of prev & next?

$("#prev").attr('data-id')
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

HainKurtSr. System AnalystCommented:
do you have a link?
0
whaleykAuthor Commented:
That was it!!!! Fabulous, thank you so very much :-)
0
whaleykAuthor Commented:
Line 34 was definatley a mistake in posting the code, it's not really there :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
AJAX

From novice to tech pro — start learning today.