Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [HTML] Generator postów
OBYWATEL
post
Post #1





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 26.03.2009

Ostrzeżenie: (0%)
-----


Witam,

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 smile.gif

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>


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>


Ten post edytował OBYWATEL 27.03.2009, 12:09:47
Go to the top of the page
+Quote Post
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




raz w if zerujesz txt:
txt = "";

a w innych ifach nie zerujesz. w tych innych jak nie zerujesz to dodajesz do istniejacej juz tresci wiec ci sie duplikuje


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 01:49