[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
www.dhtmlgoodies.com • View topic - Creating dynamic variable names (XP blue pane)
Advertisement

Creating dynamic variable names (XP blue pane)

Moderators: Calcifer, slothy

Creating dynamic variable names (XP blue pane)

Postby dbonsall » Sat Sep 02, 2006 6:43 am

dbonsall
 
Posts: 15
Joined: Sun Aug 13, 2006 2:39 am

Postby slothy » Sat Sep 02, 2006 12:51 pm

HI Dennis,

the easiest way I guess, if i have understood you correctly, is just to have a boolean variable, declared globally set to true

so you would have something like

var callAjax = true;

Once you have called the Ajax routine have it set to false. If you have the Ajax call in an if statement then it will only get called once.

So, taking your code below,my amendments in red :-

var callAjax = true; //globally declared

function loadProducts(e,inputObj)
{
if(!inputObj)inputObj = this;
var img = inputObj.getElementsByTagName('IMG')[0];
var numericId = img.id.replace(/[^0-9]/g,'');
var obj = document.getElementById('paneContent' + numericId);
if (callAjax)
// will be called first as global and set to true
{
ajaxpage('products.html?categoryindex=' + numericId);
callAjax = false;
return true;
else

{

// after call to Ajax ie ONE iteration callAjax will always remain false;
do something else that dosnt involve Ajax call...

}

}



hOpe it helps

ALex
slothy
Moderator
 
Posts: 58
Joined: Fri Aug 25, 2006 1:42 pm

Creating dynamic variable names (XP blue pane)

Postby dbonsall » Sat Sep 02, 2006 2:38 pm

Actually, I am wanting to let the ajax function run the first time any pane is clicked on. So, if there are two panes, and you click on the first pane, the ajax function is called for that pane. Then if you click on the second pane, the ajax function is called for that pane. But if you click on the first one again, the ajax function is not called again. Unfortunately, the number of panes is not going to be a fixed value (my current setup is using 66 panes), so hardcoding the variables is not an option. That's why I wanted to try and use numericId.

Thanks for the reply, though.

Dennis
dbonsall
 
Posts: 15
Joined: Sun Aug 13, 2006 2:39 am


Return to XP widget questions

Who is online

Users browsing this forum: No registered users and 6 guests

cron