I have a page which has 3 sections. On the left a static menu
e.g.
<a href="#" class="actionLink" id="newFile"><li>New File</li></a>
This can start new actions e.g.
$('.actionLink').click(function() {
var folderID; // trying set ID here
var fileName = $(this).attr('id');
$("#myAction").load('/ajax/actions/' + fileName + '.php?folder_id=' + folderID);
})
So, this loads /ajax/actions/newFile.php
In the middle is a page loaded using jquery .load()
. Within the page in the middle is a series of folders which have an ID. On click, these folders display their contents are shown on the right of the page.
e.g.
<span id="12" class="folder active99">Music</span>
$('.folder').click(function() {
var folderID = $(this).attr('id');
$("#myAction").load('/ajax/actions/links.php?folder_id=' + folderID);
})
When clicked shows contents on the right. Note variable folderID. This all works ok.
What I would like to happen is when a folder is selected in the middle, it changes the folderID
variable on the left hand menu so when a new action is chosen it corresponds to the folder its supposed to.
I've tried setting the variable everywhere i.e. in all sections var folderID;
but whatever I try doesn't carry the variable around.
Is this possible or is there a better way to do this? Am I going about it wrongly?
To summarize: When I click a folder in the middle I need it to add the variable to the left menu.
UPDATE
This is code I currently use:
$(document).ready(function(){
var folderID = '';
$('.actionLink').click(function() {
var fileName = $(this).attr('id');
$("#myAction").load('/ajax/actions/' + fileName + '.php?folder_id=' + folderID);
});
$('.folder').click(function() {
$('.folder').removeClass('active99'); // remove from all other <SPAN>s
$(this).addClass('active99'); // add onto current
var folderID = $(this).attr('id');
$("#myAction").load('/ajax/actions/links.php?folder_id=' + folderID);
});
});
I've now changed things slightly so middle section is actually included as opposed to using .load()
but still not working