Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

variable being overwritten by default?

Posted on 2011-10-06
6
Medium Priority
?
211 Views
Last Modified: 2012-05-12
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

0
Comment
Question by:whaleyk
  • 4
  • 2
6 Comments
 
LVL 61

Accepted Solution

by:
HainKurt earned 2000 total points
ID: 36925707
try modifying line 44 as:


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

Expert Comment

by:HainKurt
ID: 36925733
also you can remove line 34

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

0
 
LVL 61

Expert Comment

by:HainKurt
ID: 36925745
but where do you change the values of prev & next?

$("#prev").attr('data-id')
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 61

Expert Comment

by:HainKurt
ID: 36925749
do you have a link?
0
 

Author Closing Comment

by:whaleyk
ID: 36925781
That was it!!!! Fabulous, thank you so very much :-)
0
 

Author Comment

by:whaleyk
ID: 36925788
Line 34 was definatley a mistake in posting the code, it's not really there :-)
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I am discussing AJAX problems in IE7 and I bet this will helps many guys out here who have problems with AJAX work. Lets start with the discovery of problem and then we will talk about its different solutions. My last two projects included …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question