By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,567 Members | 1,185 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,567 IT Pros & Developers. It's quick & easy.

mootools - dynamically load ajax content in accordian panel

P: n/a
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
}
Jul 21 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Jul 21, 10:29 am, ameshkin <amir.mesh...@gmail.comwrote:
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
Jul 21 '08 #2

P: n/a
On Jul 21, 11:16*am, Peter Michaux <petermich...@gmail.comwrote:
On Jul 21, 10:29 am, ameshkin <amir.mesh...@gmail.comwrote:
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
Thank you
Jul 21 '08 #3

P: n/a
In comp.lang.javascript message <274cfaa3-5154-4960-872d-fdf07dea701d@w1
g2000prk.googlegroups.com>, Mon, 21 Jul 2008 10:29:41, ameshkin
<am**********@gmail.composted:
>
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.

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQqish topics, acronyms & links;
Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Jul 22 '08 #4

P: n/a
Peter Michaux wrote:
On Jul 21, 10:29 am, ameshkin <amir.mesh...@gmail.comwrote:
>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
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
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Jul 22 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.