www.webdeveloper.com
Page 3 of 3 FirstFirst 123
Results 31 to 32 of 32

Thread: Sudoku Game Help

  1. #31
    Join Date
    Sep 2007
    Posts
    301
    Code:
      
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
    <meta http-equiv="content-language" content="tr" >
    <style type="text/css">
    table input {width:40px; height:40px;text-align:center; font-size:16px; font-weight:bold;}
    .sag { border-right:thick double #dedede;} /* http://www.w3schools.com/cssref/pr_border-right.asp  */
    .uc {  border-right:thick double #babada;  border-bottom:thick double #bacada;}
    .alt {  border-bottom:thick double #babaca;}
    .arkarenk { background-color: #ceb; }
    .arkarenk2 { background-color: #aff; }
    .arkarenk3 { background-color: #defaad; }
    .arkarenk4 { background-color: #ade; }
    .arkarenk5 { background-color: #cafcaf; }
    .arkarenk6 { background-color: #abd; }
    .arkarenk7 { background-color: #afa; }
    .arkarenk8 { background-color: #bed; }
    .arkarenk9 { background-color: #ada; }
    .yeni {font-size:24px;background-color: #ebcede; color:#def;}
    .kolay {font-family:"Times New Roman", Times, serif; 
    font-size:24px;
    text-align:center; color:#bab;border:4px solid #fab;
    width:400px; height:50px; background-color:#ced; }
    
    </style>
    
    <script type="text/javascript">
    // http://www.webdeveloper.com/forum/showthread.php?275573-Sudoku-Game-Help/page2
    
    var A;
    function sudokuYap () {
    
    // var n= [1,2,3,4,5,6,7,8,9];
    // n dizisindeki elemanları rastgele diziyorum.
    var n= [1,2,3,4,5,6,7,8,9].sort( function() { return 0.5 - Math.random() } );
    
    // A dizisi içine n dizisinin elemanlarını hangi sırayla yerletireceğimi belirliyorum.
    A=  [n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[3],n[4],n[5],n[6],n[7],n[8],n[0],n[1],n[2],n[6],n[7],n[8],n[0],n[1],n[2],n[3],n[4],n[5],n[1],n[2],n[0],n[4],n[5],n[3],n[7],n[8],n[6],n[4],n[5],n[3],n[7],n[8],n[6],n[1],n[2],n[0],n[7],n[8],n[6],n[1],n[2],n[0],n[4],n[5],n[3],n[2],n[0],n[1],n[5],n[3],n[4],n[8],n[6],n[7],n[5],n[3],n[4],n[8],n[6],n[7],n[2],n[0],n[1],n[8],n[6],n[7],n[2],n[0],n[1],n[5],n[3],n[4]];
    
    // rastgele belirlenecek 30 inputa, değer atayayım.
    var el;
       for(var p=0; p<30; p++) {
       r= Math.floor(Math.random()*81);
       el= document.getElementById("s" + (r+1) ); 
       el.value = A[r]; 
       el.style.color="blue";
       }
    
    }
    
    // Tablodaki açılmamış 5 tane inputun değerini göstereyim.
    function ipucu() {
    var r;
    var say=0;
    var el;
       for(var k=0; k<81; k++) {
       r= Math.floor(Math.random()*81);
        el= document.getElementById("s" + (r+1)); 
        if(el.value=='') { el.value = A[r];  el.style.color="coral"; say++; }
        if(say == 5 ) { break; }  
       }
    
    }
    
    
    // Tablodaki tüm input elemanlarının değerini temizleyip yeni sudoku yapılması için fonksiyonu çağırayım.
    function temizle() {
    
    var el, k;
       for( k=0; k<81; k++) {
       
        el= document.getElementById("s" + (k+1)); 
        el.value = '';  
        el.style.color="black";
       }
    
    sudokuYap();
    }
    
    </script>
    
    </head>
    <body>
    
    <table align="center"> 
    <tr>
    <td class="sag arkarenk">
    <input type="text" id="s1">
    <input type="text" id="s2">
    <input type="text" id="s3">
    </td><td class="sag arkarenk2">
    <input type="text" id="s4">
    <input type="text" id="s5">
    <input type="text" id="s6">
    </td><td class="arkarenk3">
    <input type="text" id="s7">
    <input type="text" id="s8">
    <input type="text" id="s9">
    </td></tr>
    <tr>
    <td class="sag arkarenk">
    <input type="text" id="s10">
    <input type="text" id="s11">
    <input type="text" id="s12">
    </td><td class="sag arkarenk2">
    <input type="text" id="s13">
    <input type="text" id="s14">
    <input type="text" id="s15">
    </td><td class="arkarenk3">
    <input type="text" id="s16">
    <input type="text" id="s17">
    <input type="text" id="s18">
    </td></tr>
    <tr>
    <td class="uc arkarenk">
    <input type="text" id="s19">
    <input type="text" id="s20">
    <input type="text" id="s21">
    </td><td class="uc arkarenk2">
    <input type="text" id="s22">
    <input type="text" id="s23">
    <input type="text" id="s24">
    </td><td class="alt arkarenk3">
    <input type="text" id="s25">
    <input type="text" id="s26">
    <input type="text" id="s27">
    </td></tr>
    <tr>
    <td class="sag arkarenk4">
    <input type="text" id="s28">
    <input type="text" id="s29">
    <input type="text" id="s30">
    </td><td class="sag arkarenk5">
    <input type="text" id="s31">
    <input type="text" id="s32">
    <input type="text" id="s33">
    </td><td class="arkarenk6">
    <input type="text" id="s34">
    <input type="text" id="s35">
    <input type="text" id="s36">
    </td></tr>
    <tr>
    <td class="sag arkarenk4">
    <input type="text" id="s37">
    <input type="text" id="s38">
    <input type="text" id="s39">
    </td><td class="sag arkarenk5">
    <input type="text" id="s40">
    <input type="text" id="s41">
    <input type="text" id="s42">
    </td><td class="arkarenk6">
    <input type="text" id="s43">
    <input type="text" id="s44">
    <input type="text" id="s45">
    </td></tr>
    <tr>
    <td class="uc arkarenk4">
    <input type="text" id="s46">
    <input type="text" id="s47">
    <input type="text" id="s48">
    </td><td class="uc arkarenk5">
    <input type="text" id="s49">
    <input type="text" id="s50">
    <input type="text" id="s51">
    </td><td class="alt arkarenk6">
    <input type="text" id="s52">
    <input type="text" id="s53">
    <input type="text" id="s54">
    </td></tr>
    <tr>
    <td class="sag arkarenk7">
    <input type="text" id="s55">
    <input type="text" id="s56">
    <input type="text" id="s57">
    </td><td class="sag arkarenk8">
    <input type="text" id="s58">
    <input type="text" id="s59">
    <input type="text" id="s60">
    </td><td class="arkarenk9">
    <input type="text" id="s61">
    <input type="text" id="s62">
    <input type="text" id="s63">
    </td></tr>
    <tr>
    <td class="sag arkarenk7">
    <input type="text" id="s64">
    <input type="text" id="s65">
    <input type="text" id="s66">
    </td><td class="sag arkarenk8">
    <input type="text" id="s67">
    <input type="text" id="s68">
    <input type="text" id="s69">
    </td><td class="arkarenk9">
    <input type="text" id="s70">
    <input type="text" id="s71">
    <input type="text" id="s72">
    </td></tr>
    <tr>
    <td class="sag arkarenk7">
    <input type="text" id="s73">
    <input type="text" id="s74">
    <input type="text" id="s75">
    </td><td class="sag arkarenk8">
    <input type="text" id="s76">
    <input type="text" id="s77">
    <input type="text" id="s78">
    </td><td class="arkarenk9">
    <input type="text" id="s79">
    <input type="text" id="s80">
    <input type="text" id="s81">
    </td></tr>
    </table>
    <br>
    <div align="center">
    <input type="button" value="yeni sudoku" onclick="temizle()" class="yeni"><br><br>
    
    <input type="button" value="Her zorlukla birlikte bir kolaylık vardır." onclick="ipucu()" class="kolay" >
    <br><br><br>
    Sudokuyu çözerken yardıma ihtiyacın olursa "Her zorlukla birlikte bir kolaylık vardır" butonuna tıklayarak yardım alabilirsin!
    </div>
    <script type="text/javascript">
    
    sudokuYap();
    
    </script>
    
    </body>
    </html>
    Last edited by Ayşe; 04-14-2013 at 05:10 PM.
    İyiliği emret. Kötülükten alıkoy. (31/16)

    hasbunallahuVeNimelVekil++

  2. #32
    Join Date
    Mar 2013
    Posts
    58
    Sorry about this guys. I'm almost done, I've just got one problem left.

    Code:
    for(var i = 0; i < (grid.length+1); i++)
    		{	
    		
    		var temp = "<h2>" + solution[i] + "</h2>";
    		
    		
    			for(var q = 0; q < exclude.length; q++)
    			{		
    
    				if( grid[i].innetHTML == temp)
    				{
    					grid[i].style.backgroundColor = "red";
    														
    				}
    				else
    				{
    					continue;
    				}
    			}
    			
    		}
    Basically when grid[i]== temp then backgroundColor should = red. The problem is it won't change. I'm trying to change the background of an input feild, this works on anything else, but not on the input feilld.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles