Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [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 (IMG:http://forum.php.pl/style_emoticons/default/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

Posty w temacie
- OBYWATEL   [HTML] Generator postów   27.03.2009, 12:10:02
- - nospor   raz w if zerujesz txt: txt = ""; a w in...   27.03.2009, 12:10:32


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

 



RSS Aktualny czas: 26.09.2025 - 22:58