Pokaż wyniki od 1 do 3 z 3

Wątek: Problem ... karta do BINGO

  1. #1
    Zarejestrowany Awatar Mati
    Dołączył
    May 2012
    Posty
    53

    Domyślnie Problem ... karta do BINGO

    Otóż trochę historii ... Postanowiłem nauczyć się js i ajaxa, więc zakupiłem książkę. Zabrałem się za jej czytanie i natrafiłem na "tworzenie karty do BINGO".
    Tu zaczyna się problem ... spisałem wszystko z książki, przeanalizowałem. Uruchomiłem przeglądarkę i daną stronę, lecz ta karta nie działa jak powinna ponieważ wyświetla się numerek tylko w jednym okienku. Jestem zielony w tym temacie i nie wiem co jest nie tak ...

    Poniżej podaje kod :

    Kod:
    <!DOCTYPE>
    <html>
    
    <head>
    <meta http-equiv='Content-type' content='text/html; charset=utf-8' />
    <link type="text/css" rel="stylesheet" href="css_bingo.css"/>
    	<script>
    		
    	window.onload = initAll;
    	
    	function initAll() {
    		for (var i=0; i<24; i++) {
    			var newNum = Math.floor(Math.random() * 75) +1;
    			
    			document.getElementById("square" + i).innerHTML = newNum;
    		}
    	}
    
    
    	</script>
    
    </head>
    <body>
    
    <h1> Karta do bingo !</h1>
    <br/>
    	<table>
    	<tr>
    		<th width="20%">B</th>
    		<th width="20%">I</th>
    		<th width="20%">N</th>
    		<th width="20%">G</th>
    		<th width="20%">O</th>
    	</tr>
    	<tr>
    		<td id="square0">&nbsp;</td>
    		<td id="square5">&nbsp;</td>
    		<td id="square10">&nbsp;</td>
    		<td id="square14">&nbsp;</td>
    		<td id="square19">&nbsp;</td>
    	</tr>
    	<tr>
    		<td id="square5">&nbsp;</td>
    		<td id="square6">&nbsp;</td>
    		<td id="square7">&nbsp;</td>
    		<td id="square8">&nbsp;</td>
    		<td id="square9">&nbsp;</td>
    	</tr>
    	<tr>
    		<td id="square2">&nbsp;</td>
    		<td id="square7">&nbsp;</td>
    		<td id="free">Wolne</td>
    		<td id="square16">&nbsp;</td>
    		<td id="square21">&nbsp;</td>
    	</tr>
    	<tr>
    		<td id="square3">&nbsp;</td>
    		<td id="square8">&nbsp;</td>
    		<td id="square12">&nbsp;</td>
    		<td id="square17">&nbsp;</td>
    		<td id="square22">&nbsp;</td>
    	</tr>
    	<tr>
    		<td id="square4">&nbsp;</td>
    		<td id="square9">&nbsp;</td>
    		<td id="square13">&nbsp;</td>
    		<td id="square18">&nbsp;</td>
    		<td id="square23">&nbsp;</td>
    	</tr>
    	</table>
    	<p><a href="bingo.html" id="reload">Kilknij tutaj</a> aby przygotować nową kartę</p>
    </body>
    </html>
    Proszę o pomoc

  2. #2
    Aktywny
    Dołączył
    Jul 2008
    Posty
    866

    Domyślnie

    A masz element o id "square1"? Nie wydaje mi się..

    Masz dwa razy square5.. to kolejny błąd.

    Po prostu coś pomieszałeś z numerami..
    To działa normalnie:

    Kod:
    <h1> Karta do bingo !</h1>
    <br/>
        <table>
        <tr>
            <th width="20%">B</th>
            <th width="20%">I</th>
            <th width="20%">N</th>
            <th width="20%">G</th>
            <th width="20%">O</th>
        </tr>
        <tr>
            <td id="square0">&nbsp;</td>
            <td id="square1">&nbsp;</td>
            <td id="square2">&nbsp;</td>
            <td id="square3">&nbsp;</td>
            <td id="square4">&nbsp;</td>
        </tr>
        <tr>
            <td id="square5">&nbsp;</td>
            <td id="square6">&nbsp;</td>
            <td id="square7">&nbsp;</td>
            <td id="square8">&nbsp;</td>
            <td id="square9">&nbsp;</td>
        </tr>
        <tr>
            <td id="square10">&nbsp;</td>
            <td id="square11">&nbsp;</td>
            <td id="free">Wolne</td>
            <td id="square12">&nbsp;</td>
            <td id="square13">&nbsp;</td>
        </tr>
        <tr>
            <td id="square14">&nbsp;</td>
            <td id="square15">&nbsp;</td>
            <td id="square16">&nbsp;</td>
            <td id="square17">&nbsp;</td>
            <td id="square18">&nbsp;</td>
        </tr>
        <tr>
            <td id="square19">&nbsp;</td>
            <td id="square20">&nbsp;</td>
            <td id="square21">&nbsp;</td>
            <td id="square22">&nbsp;</td>
            <td id="square23">&nbsp;</td>
        </tr>
        </table>
        <p><a href="bingo.html" id="reload">Kilknij tutaj</a> aby przygotować nową kartę</p>
    </body>
    </html>
    Ostatnio edytowane przez Drikam ; 17-11-2012 o 15:12

  3. #3
    Zarejestrowany Awatar Mati
    Dołączył
    May 2012
    Posty
    53

    Domyślnie

    Faktycznie dwa razy 5 miałem. Spisywałem kod z książki i jest 5 dwa razy. Nie wiem o co chodzi z tą grą bingo, ale działa teraz.
    Dzięki temat do zamknięcia!

Informacje o wątku

Użytkownicy przeglądający ten wątek

Aktualnie 1 użytkownik(ów) przegląda ten wątek. (0 zarejestrowany(ch) oraz 1 gości)

Podobne wątki

  1. Problem z cs i karta graficzną
    Przez eXXXu w dziale MMOFPS
    Odpowiedzi: 8
    Ostatni post / autor: 28-07-2011, 09:58

Zakładki

Uprawnienia umieszczania postów

  • Nie możesz zakładać nowych tematów
  • Nie możesz pisać wiadomości
  • Nie możesz dodawać załączników
  • Nie możesz edytować swoich postów
  •