How do i edit my js so the form clears before putting out the output
<p>hello im working on a html color maker and found a javascript somewhere only this script deosnt clear out the output when you press make code </p>

<p>so my questions is what do i have to add to my code so it clears the output before putting in the new results</p>

<p>here is my javascript :</p>

<pre><code>function is_valid(color_list)
{
var colors = (color_list.toLowerCase()).split(',');
var hex    = '0123456789abcdef';
var valid  = true;

for (var i = 0; (i &lt; colors.length) &amp;&amp; valid; i++)
{
    if (colors[i].length != 6) valid = false;

    for (var j = 0; j &lt; colors[i].length; j++)
    {
        if (hex.indexOf(colors[i].charAt(j)) &lt; 0) valid = false;
    }
}

return valid;
}

function hex_to_dec(n)
{
// n will always be passed in as a string

var c = '0123456789abcdef';

n = n.toLowerCase();

return c.indexOf(n.charAt(0)) * 16 + c.indexOf(n.charAt(1));
}

function hex_to_rgb(hex)
{
// hex will always be passed in as a string

var srgb = '';

for (var i = 0; i &lt; 6; i += 2)
    srgb = srgb + hex_to_dec(hex.substring(i, i + 2)) + ',';

return srgb.substring(0, srgb.length - 1);
}

function two_color_fade(txt, color1, color2)
{
var htm = '';

if (txt.length == 0) return htm;

// color1 and color2 are strings from the comma delimited color_list

// s1 and s2 are now in form 255,00,33

var s1 = hex_to_rgb(color1);
var c1 = s1.split(',');

var s2 = hex_to_rgb(color2);
var c2 = s2.split(',');

for (var i = 0; i &lt; 3; i++)
{
    c1[i] = parseInt(c1[i]);
    c2[i] = parseInt(c2[i]);
}

var inc = new Array(3);

for (var i = 0; i &lt; 3; i++)
{
    if (txt.length - 1 &gt; 0)
    {
        inc[i] = (c2[i] - c1[i]) / (txt.length - 1);
    }
    else
        inc[i] = c2[i];
}

for (var i = 0; i &lt; txt.length; i++)
{
    htm = htm + '&lt;font color="' + rgb_to_hex(c1[0], c1[1], c1[2]) + '"&gt;' + txt.charAt(i) + '&lt;\/font&gt;';

    // test print out
    //htm += '&lt;font color="' + rgb_to_hex_wtv(c1[0], c1[1], c1[2]) + '"&gt;' +
    //i + ': ' + c1[0] + ',' + c1[1] + ',' + c1[2] + '&lt;\/font&gt;&lt;br&gt;';

    for (var j = 0; j &lt; 3; j++) c1[j] += inc[j];
}

return htm;
}

function multi_color_fade(txt, color_list)
{
var htm = '';
var color_count = 0;
var chunk_count = 0;
var chunks = new Array();

var colors = (color_list.toLowerCase()).split(',');

var num_chunks = colors.length - 1;

var quotient  = Math.floor(txt.length / num_chunks);
var remainder = txt.length % num_chunks;

for (var i = 0; i &lt; num_chunks; i++)
{
    chunks[i] = quotient;

    if (i &gt;= (num_chunks - remainder)) chunks[i]++;
}

for (var i = 0; i &lt; txt.length; i += chunks[chunk_count++])
{
    // The substr method would be eaiser, but WebTV can't handle substr.
    // str.substr(i, j) is same as str.substring(i, i + j)
    htm += two_color_fade(txt.substring(i, i + chunks[chunk_count]), colors[color_count], colors[color_count + 1]);

    color_count++;
}

return htm;
}

function fade(frm)
{
var col_list = '';

var txt = frm.intxt.value;

// preset or custom color scheme?
    col_list = frm.selPresets.options[frm.selPresets.selectedIndex].value;

if (txt.length == 0)
{
    alert('You need to enter some text.');
    frm.intxt.focus();
    return;
}


frm.outtxt.value += multi_color_fade(txt, col_list);
}


function rgb_to_hex(r, g, b)
{
// r, g, and b are numbers, not strings

// correct function returns 255 if n &gt; 255 and 0 if n &lt; 0

// The "correct" function doesn't really need to be called, since
// rgb_to_hex will take care of anything &lt; 256 or &gt; -1, but just
// to be on the safe (WebTV) side...
r = correct(r);
g = correct(g);
b = correct(b);

var h = ((r &lt;&lt; 16) | (g &lt;&lt; 8) | (b)).toString(16);

while (h.length &lt; 6) h = '0' + h;

return '#' + h;
}

function correct(n){if(n&gt;255)return 255;if(n&lt;0)return 0;return n}

// --&gt;
</code></pre>
