mootools - dynamically load ajax content in accordian panel

A

ameshkin

Hi Everybody,

I'm just now learning javascript and I'm using mootools. What I want
to do is to dynamically load a php page into accordian panel 2,
depending on which radio button is selected in accordian panel 1.
Here is a simplified version of my code.

window.addEvent('domready', function() {
var accordion = new Accordion('h3.atStart', 'div.atStart', {
display: 0, //will open the 1st panel at start
opacity: false,
onActive: function(toggler, element){
toggler.setStyle('color', '#000000');
},

onBackground: function(toggler, element){
toggler.setStyle('color', '#222');
}
}, $('accordion'));


//Open Accordion Panels
$('next1').addEvent('click', function() {
accordion.display(1);
});
$('next2').addEvent('click', function() {

accordion.display(2);
//AjxCln();
});
$('next3').addEvent('click', function() {
accordion.display(3);
});
$('next4').addEvent('click', function() {
accordion.display(4);
});

$('prev1').addEvent('click', function() {
accordion.display(0);
});
$('prev2').addEvent('click', function() {
accordion.display(1);
});
$('prev3').addEvent('click', function() {
accordion.display(2);
});
$('prev4').addEvent('click', function() {
accordion.display(3);
});

});
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value
+"'");
if (restore) selObj.selectedIndex=0;
}



var accordion;
var accordionTogglers;
var accordionContents;

window.onload = function() {
accordionTogglers = document.getElementsByClassName('accToggler');

accordionTogglers.each(function(toggler){
//remember the original color
toggler.origColor = toggler.getStyle('background-color');
//set the effect
toggler.fx = new Fx.Color(toggler, 'background-color');
});

accordionContents = document.getElementsByClassName('accContent');

accordion = new Fx.Accordion(accordionTogglers, accordionContents,{
//when an element is opened change the background color to blue
onActive: function(toggler){
toggler.fx.toColor('#6899CE');
},
onBackground: function(toggler){
//change the background color to the original (green)
//color when another toggler is pressed
toggler.setStyle('background-color', toggler.origColor);
}
});
}



function AjxCln() {

//new code below for ajax
var showSuccess = new function(req){
alert(req);
};

//a GET request
//new XHR({method: 'get', onSucces: showSuccess}).send('location/
myscript.php', 'answerme=1&q=test');

//find out which radio button was checked

var a1 = document.getElementById('svc_tp_1').checked; //these are the
radio buttons, depending on which one is checked, I want the variable
PAGE to be a different number. The php file will determine what
content to show based on what $page is equal to!
var a2 = document.getElementById('svc_tp_2').checked;

if (a1 == true) {
var page = '1';
} elseif(a2 == true) {
var page = '2';
} else {

}




//POST ajax
new XHR({onSuccess: showSucces}).send('AJAX/step-2.php', 'page=' +
page);

//above code ajax


}
 
P

Peter Michaux

Hi Everybody,

I'm just now learning javascript and I'm using mootools. What I want
to do is to dynamically load a php page into accordian panel 2,
depending on which radio button is selected in accordian panel 1.
Here is a simplified version of my code.

comp.lang.javascript is the best place on the Internet for discussion
about JavaScript in general.

Questions specific to Mootools will likely best be answered on the
Mootools group

http://groups.google.com/group/mootools-users

Peter
 
D

Dr J R Stockton

In comp.lang.javascript message <274cfaa3-5154-4960-872d-fdf07dea701d@w1
g2000prk.googlegroups.com>, Mon, 21 Jul 2008 10:29:41, ameshkin
if (a1 == true) {
var page = '1';
} elseif(a2 == true) {
var page = '2';
} else {

}

Anyone who thinks that == true is needed there should start learning
JavaScript again.
 
T

Thomas 'PointedEars' Lahn

Peter said:
comp.lang.javascript is the best place on the Internet for discussion
about JavaScript in general.

Questions specific to Mootools will likely best be answered on the
Mootools group

http://groups.google.com/group/mootools-users

Whereas "best" should be understood as "fitted to satisfy mootools users",
not "technically correct" or "tainted by a sufficient level of development
experience in the languages and field in question".


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top