Sectoare pe tabele...###

Secţiune dedicată începatorilor.

Moderatori: Moderatori, Start Moderator

Avatar utilizator
Khamoaset
Average Member
Mesaje: 160
Membru din: Joi Iul 21, 2011 4:29 pm
Contact:

Sectoare pe tabele...###

Mesajde Khamoaset » Sâm Dec 07, 2013 4:21 pm

Salutare, am incercat sa fac tabele cu 20 coloane si randuri in mod normal calcule.. dar si pe partea cu sectoare. de exemplu: daca sunt pe sectorul 2 tabelul cu class si textul sa fie schimbate dar calculul tabelului din top si left sa ramana cum este el fara a modifica din numarul sectorului.. daca e pe sect. 2 sa inceapa pe text si class fiecarui tabel div de la 20:1 ..20:20; ... si daca ma misc pe sectorul 7 sa fie calcul de la 70:1... 70:70..
din url se poate modifica sector: http://localhost/sector.php?sector=2

Cod: Selectaţi tot

<script type='text/javascript'>
///////////////////////////////////////////////////////
//                  BEGIN                   //
///////////////////////////////////////////////////////
var qs = (function(a) {
    if (a == "") return {};
    var b = {};
    for (var i = 0; i < a.length; ++i)
    {
        var p=a[i].split('=');
        if (p.length != 2) continue;
        b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
    }
    return b;
})(window.location.search.substr(1).split('&'));
///////////////////////////////////////////////////////
//                   END                   //
///////////////////////////////////////////////////////
var x,y,i,j,h,st,pt,tilexy,nrclss,nrdraw,sectbegin,sectend;
tilexy = parseInt(20);
sectbegin = (qs['sector'] == 0 || qs['sector'] == '') ? 1 : qs['sector'];
sectend = (sectbegin * tilexy);

   for (i=sectbegin; i<sectend; i++) {
      for (j=sectbegin; j<sectend; j++) {
         nrclss = (i+"_"+j);
         nrdraw = (i+":"+j);
      };
   };

document.write('de la <b>'+sectbegin+'</b> la <b>'+sectend+'</b>');

   for (x=1; x<tilexy; x++) {
      for (y=1; y<tilexy; y++) {
         st = (y * 52); //top-y
         pt = (x * 52); //left-x

         document.write("<div class='"+nrclss+"' style='position:absolute; width:50px; height:50px; background:gray; top:"+st+"px; left:"+pt+"px;'>"+nrdraw+"</div>");
      
      };
   };
</script>



... uite cum sa fie exemplu ca sector 2 .. 20 randuri si 20 coloane :
----------------------------------------------------------------------------
| 20:1 | 20:2 | 20:3 | 20:4 | 20:5 | 20:6 | 20:7 | ..... | 20:20 |
----------------------------------------------------------------------------
| 21:1 | 21:2 | 21:3 | 21:4 | 21:5 | 21:6 | 21:7 | ..... | 21:20 |
----------------------------------------------------------------------------
...............................................................................
----------------------------------------------------------------------------
| 38:1 | 38:2 | 38:3 | 38:4 | 38:5 | 38:6 | 38:7 | ..... | 38:20 |
----------------------------------------------------------------------------
| 39:1 | 39:2 | 39:3 | 39:4 | 39:5 | 39:6 | 39:7 | ..... | 39:20 |
----------------------------------------------------------------------------

...iar ptr sector 7.... 20 coloane si 20 randuri :
----------------------------------------------------------------------------
| 70:1 | 70:2 | 70:3 | 70:4 | 70:5 | 70:6 | 70:7 | ..... | 70:20 |
----------------------------------------------------------------------------
| 71:1 | 71:2 | 71:3 | 71:4 | 71:5 | 71:6 | 71:7 | ..... | 71:20 |
----------------------------------------------------------------------------
...............................................................................
----------------------------------------------------------------------------
| 138:1 | 138:2 | 138:3 | 138:4 | 138:5 | 138:6 | 138:7 | ..... | 138:20 |
----------------------------------------------------------------------------
| 139:1 | 139:2 | 139:3 | 139:4 | 139:5 | 139:6 | 139:7 | ..... | 139:20 |
----------------------------------------------------------------------------

... sa nu fie dublate tabelul... doar sa fie schimbate cifrele de la INCEPUT pana la SFARSIT dupa sector... in class si text pe tabel div.. cred ca ati inteles ca vreau sa ma ajutati..


"`"Atata timp cat putem zambi, cauza nu-i inca pierduta!"`"

'*'`Nimic nu este mai presus pe Pamant decat OMUL, nimic nu este mai presus in OM decat MINTEA si SUFLETUL!`'*'

Avatar utilizator
LyVyU VT
Senior Member
Mesaje: 224
Membru din: Lun Sep 29, 2008 8:58 am
Localitate: Râmnicu Sărat
Contact:

Re: Sectoare pe tabele...###

Mesajde LyVyU VT » Joi Ian 23, 2014 10:20 pm

Mai întâmpinați această problemă sau ați rezolvat?

Avatar utilizator
LyVyU VT
Senior Member
Mesaje: 224
Membru din: Lun Sep 29, 2008 8:58 am
Localitate: Râmnicu Sărat
Contact:

Re: Sectoare pe tabele...###

Mesajde LyVyU VT » Mar Ian 28, 2014 6:49 pm

Cod: Selectaţi tot

<script type='text/javascript'>
  var qs = (function(a) {
      if (a == "") return {};
      var b = {};
      for (var i = 0; i < a.length; ++i)
      {
          var p=a[i].split('=');
          if (p.length != 2) continue;
          b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
      }
      return b;
  })(window.location.search.substr(1).split('&'));

  var x,y,i,j,h,st,pt,tilexy,nrclss,nrdraw,sectbegin,sectend;
  tilexy = 20;
  sectbegin = (qs['sector'] == 0 || qs['sector'] == '') ? 1 : qs['sector'];
  sectend = (sectbegin * tilexy);

  document.write('de la <b>'+sectbegin+'</b> la <b>'+sectend+'</b>');
 
  for (x=1; x<=tilexy; x++) {
    current_x = parseInt(sectbegin) * 10 + x - 1; 
    for (y=1; y<=tilexy; y++) {
      st = (x * 52); //top-y
      pt = (y * 52); //left-x
     
      current_y = y;

      document.write("<div class='"+current_x+"_"+current_y+"' style='position:absolute; width:50px; height:50px; background:gray; top:"+st+"px; left:"+pt+"px;'>"+current_x+":"+current_y+"</div>");
     
    };
  };
</script>


Înapoi la “PHP Incepători”

Cine este conectat

Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 35 vizitatori