Subash A Subash A - 6 months ago 22
jQuery Question

How to call a function inside a main function in javascript

function chart(){
Barchart();
Linechart();
function Barchart(){
}
function Linechart(){
}
}


Chart()
is main parent function. Inside I have two chart functions. I have to call only line chart.
Chart();
will execute both barchart and linechart.
but I need to call only line chart.

Answer

Yes, this is true. Both will execute in the order given. You need to provide some sort of selection. Either using an if/then or some other way.

If(myChecbox.isSelected){
barchart();}
else{
linechart();
}

Ask yourself, what is it that is making the choice? Let me know what you come up with. You will need to place the called functions outside of your method...as stated in the others post.

Comments