Change the code of a javascript function
<p>Actually my idea is the following: i have a div tag that displays the result of a function called "afficher_general()" inside a script tag, and a button that calls a first function called "Ajouter_general()" that's supposed to change a string inside the function "afficher_general()" </p>

<pre><code>var general = document.getElementById("general");
general.innerHTML = general.innerHTML.replace('//WRITE', ch);
</code></pre>

<p>the button is as follows:</p>

<pre><code>&lt;input type="button" value="ajouter au graphe general" id="id1" onClick="Ajouter_general();afficher_general();" /&gt;
</code></pre>

<p>But this doesn't seem to work because i've been told that a script is loaded only once and it cannot be changed. So is there any solution ? Thanks in advance.</p>

<p>So i'll add what contain the functions. Actually i'm working with Amcharts . the function afficher_generalis as follows:</p>

<pre><code>&lt;script name="general" id="general" type="text/javascript"&gt;
    function afficher_general()
    {

                    chart = new AmCharts.AmSerialChart();
                    chart.dataProvider = chartData;
                    chart.categoryField = "country";
                    chart.startDuration = 1;                
                    // WRITE
                    chart.write("chartContainer");


    }
&lt;/script&gt;
</code></pre>

<p>instead of the comment //WRITE i wish to add the a code everytime the button is pressed. the function is as follows:</p>

<pre><code>function Ajouter_general(ind){
var ch="";
var couleur = getSelectValueId("background-color"+ind);
var transparence = getSelectValueId("transparence"+ind);
var type = get_radio_value_type(ind);
var balloon = getSelectValueId("balloon-color"+ind);
if(type == "column")
                {
                ch=ch+"var graph"+ind+" = new AmCharts.AmGraph();";
                                ch=ch+"graph"+ind+".valueField = "+"visits"+";"
                ch=ch+"graph"+ind+".balloonColor = "+balloon+";";
                                ch=ch+"graph"+ind+".type = "+type+";";
                                ch=ch+"graph"+ind+".fillAlphas = "+transparence+";";
                ch=ch+"graph"+ind+".fillColors = ["+couleur+"];";
                ch=ch+"graph"+ind+".lineColor = ["+couleur+"];";
                ch=ch+"chart.addGraph(graph"+ind+");";
                ch=ch+"// WRITE";
                }
var general = document.getElementById("general");
general.innerHTML = general.innerHTML.replace('//WRITE', ch);
}
</code></pre>

<p>since Amcharts uses the script to draw graphs inside a chart, i would like to be able to dynamically add those graphs everythime the button is pressed.</p>
