Stworzyłem taki oto generator postów, wszystko byłoby OK, gdyby nie mały problem, który polega na tym, że jak wpisuję do formularza jakieś dane to generując je otrzymuje wynik podwojony tudzież potrojony. Z racji tego, że jestem początkujący proszę o wszelaką pomoc

Kod
<script type="text/javascript">
function doStuff()
{
var txt = "";
document.getElementById("gen").value = "";
if (document.getElementById("cover").value != ""){
txt = "";
txt += "[img]";
txt += document.getElementById("cover").value; //COVER
txt += "[/img]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("albuminfo").value != ""){
txt = "";
txt += "[img]";
txt += document.getElementById("albuminfo").value; //ALBUMINFO
txt += "[/img]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("artist").value != ""){
txt += "[b][i][size=12][color=#a03e64]Artist:[/color] ";
txt += document.getElementById("artist").value; //ARTIST
txt += "[/size][/i][/b]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("album").value !=""){
txt += "[b][i][size=12][color=#a03e64]Album:[/color] ";
txt += document.getElementById("album").value; //ALBUM
txt += "[/size][/i][/b]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("date").value != ""){
txt += "[b][i][size=12][color=#a03e64]Date:[/color] ";
txt += document.getElementById("date").value; //DATE
txt += "[/size][/i][/b]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("genre").value != ""){
txt += "[b][i][size=12][color=#a03e64]Genre:[/color] ";
txt += document.getElementById("genre").value; //GENRE
txt += "[/size][/i][/b]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("format").value != ""){
txt += "[b][i][size=12][color=#a03e64]Format:[/color] ";
txt += document.getElementById("format").value; //FORMAT
txt += "[/size][/i][/b]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("tracklist").value != ""){
txt = "";
txt += "[img]";
txt += document.getElementById("tracklist").value; //TRACKLIST
txt += "[/img]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("info").value != ""){
txt = "";
txt += "[size=12][i]\n";
txt += document.getElementById("info").value; //TRACKLIST
txt += "[/i][/size]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("rapidshare").value != ""){
txt = "";
txt += "[img]";
txt += document.getElementById("rapidshare").value; //RAPIDSHARE
txt += "[/img]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("downlinks").value != ""){
txt = "";
txt += "\n";
txt += document.getElementById("downlinks").value; //DOWNLOAD
txt += "\n";
document.getElementById("gen").value += txt;
}
}
</script>
function doStuff()
{
var txt = "";
document.getElementById("gen").value = "";
if (document.getElementById("cover").value != ""){
txt = "";
txt += "[img]";
txt += document.getElementById("cover").value; //COVER
txt += "[/img]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("albuminfo").value != ""){
txt = "";
txt += "[img]";
txt += document.getElementById("albuminfo").value; //ALBUMINFO
txt += "[/img]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("artist").value != ""){
txt += "[b][i][size=12][color=#a03e64]Artist:[/color] ";
txt += document.getElementById("artist").value; //ARTIST
txt += "[/size][/i][/b]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("album").value !=""){
txt += "[b][i][size=12][color=#a03e64]Album:[/color] ";
txt += document.getElementById("album").value; //ALBUM
txt += "[/size][/i][/b]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("date").value != ""){
txt += "[b][i][size=12][color=#a03e64]Date:[/color] ";
txt += document.getElementById("date").value; //DATE
txt += "[/size][/i][/b]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("genre").value != ""){
txt += "[b][i][size=12][color=#a03e64]Genre:[/color] ";
txt += document.getElementById("genre").value; //GENRE
txt += "[/size][/i][/b]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("format").value != ""){
txt += "[b][i][size=12][color=#a03e64]Format:[/color] ";
txt += document.getElementById("format").value; //FORMAT
txt += "[/size][/i][/b]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("tracklist").value != ""){
txt = "";
txt += "[img]";
txt += document.getElementById("tracklist").value; //TRACKLIST
txt += "[/img]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("info").value != ""){
txt = "";
txt += "[size=12][i]\n";
txt += document.getElementById("info").value; //TRACKLIST
txt += "[/i][/size]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("rapidshare").value != ""){
txt = "";
txt += "[img]";
txt += document.getElementById("rapidshare").value; //RAPIDSHARE
txt += "[/img]\n";
document.getElementById("gen").value += txt;
}
if (document.getElementById("downlinks").value != ""){
txt = "";
txt += "\n";
txt += document.getElementById("downlinks").value; //DOWNLOAD
txt += "\n";
document.getElementById("gen").value += txt;
}
}
</script>
Kod
<form name="frm" action="#">
<table class="kiri">
<tbody>
<tr>
<td>Cover:</td>
<td><input id="cover" maxlength="200" size="65"></td>
</tr>
<tr>
<td>AlbumInformation:</td>
<td><input id="albuminfo" maxlength="200" size="65"></td>
</tr>
<tr>
<td>Artist:</td>
<td><input id="artist" maxlength="100" size="70"></td>
</tr>
<tr>
<td>Album:</td>
<td><input id="album" maxlength="100" size="70"></td>
</tr>
<tr>
<td>Date:</td>
<td><input id="date" maxlength="100" size="70"></td>
</tr>
<tr>
<td>Genre:</td>
<td><input id="genre" maxlength="100" size="70"></td>
</tr>
<tr>
<td>Format:</td>
<td><input id="format" maxlength="100" size="70"></td>
</tr>
<tr>
<td>TrackListing:</td>
<td><input id="tracklist" maxlength="200" size="65"></td>
</tr>
<tr>
<td>TrackList:</td>
<td><textarea id="info" cols="50" rows="5"></textarea></td>
</tr>
<tr>
<td>Rapidshare:</td>
<td><input id="rapidshare" maxlength="200" size="65"></td>
</tr>
<tr>
<td>Download:</td>
<td><textarea id="downlinks" cols="50" rows="5"></textarea></td>
</tr>
<tr>
<td style="text-align: right;" colspan="2"><input class="btn" onclick="doStuff()" value="Generuj" type="button"><input class="btn" type="reset"></td>
</tbody>
</table>
<table class="kiri">
<tbody>
<tr>
<td>Cover:</td>
<td><input id="cover" maxlength="200" size="65"></td>
</tr>
<tr>
<td>AlbumInformation:</td>
<td><input id="albuminfo" maxlength="200" size="65"></td>
</tr>
<tr>
<td>Artist:</td>
<td><input id="artist" maxlength="100" size="70"></td>
</tr>
<tr>
<td>Album:</td>
<td><input id="album" maxlength="100" size="70"></td>
</tr>
<tr>
<td>Date:</td>
<td><input id="date" maxlength="100" size="70"></td>
</tr>
<tr>
<td>Genre:</td>
<td><input id="genre" maxlength="100" size="70"></td>
</tr>
<tr>
<td>Format:</td>
<td><input id="format" maxlength="100" size="70"></td>
</tr>
<tr>
<td>TrackListing:</td>
<td><input id="tracklist" maxlength="200" size="65"></td>
</tr>
<tr>
<td>TrackList:</td>
<td><textarea id="info" cols="50" rows="5"></textarea></td>
</tr>
<tr>
<td>Rapidshare:</td>
<td><input id="rapidshare" maxlength="200" size="65"></td>
</tr>
<tr>
<td>Download:</td>
<td><textarea id="downlinks" cols="50" rows="5"></textarea></td>
</tr>
<tr>
<td style="text-align: right;" colspan="2"><input class="btn" onclick="doStuff()" value="Generuj" type="button"><input class="btn" type="reset"></td>
</tbody>
</table>