Jump to content
php.lv forumi

klavsr

Reģistrētie lietotāji
  • Posts

    60
  • Joined

  • Last visited

Posts posted by klavsr

  1. Mēģināju abas metodes, bet izskatās, ka kaut ko daru galīgi garām.. :(

     

    <script type="text/javascript">
    var teksti = ['teksts1','teksts2','teksts3','teksts4','teksts5'];
    
    for(var i=1; i<4; i++)
    {
    document.GetElementBy('nosaukums_'+i).style.fontWeight = 'normal';
    }
    </script>
    
    <div id="tekstiem"></div>
    
    <a href="#" id="nosaukums_1" onclick="document.getElementById('tekstiem').innerHTML = teksti[0]; this.style.fontWeight = 'bold'; return false;">1</a>
    <a href="#" id="nosaukums_2" onclick="document.getElementById('tekstiem').innerHTML = teksti[1]; this.style.fontWeight = 'bold'; return false;">2</a>
    <a href="#" id="nosaukums_3" onclick="document.getElementById('tekstiem').innerHTML = teksti[2]; this.style.fontWeight = 'bold'; return false;">3</a>

    Bolds uzliekās katram, bet nost neiet.

     

     

    <script type="text/javascript">
    var teksti = ['teksts1','teksts2','teksts3','teksts4','teksts5'];
    
    var mans_bolds='a1';
    function uz_bold(id)
    {
    document.GetElementBy(mans_bolds).style.fontWeight = 'normal';
    document.GetElementBy(id).style.fontWeight = 'bold';
    mans_bolds=id;  
    return false;
    }
    </script>
    
    <div id="tekstiem"></div>
    
    <a href="#" id="a1" onclick="document.getElementById('tekstiem').innerHTML = teksti[0]; uz_bold('a1'); return false;">1</a>
    <a href="#" id="a2" onclick="document.getElementById('tekstiem').innerHTML = teksti[1]; uz_bold('a2'); return false;">2</a>
    <a href="#" id="a3" onclick="document.getElementById('tekstiem').innerHTML = teksti[2]; uz_bold('a3'); return false;">3</a>

    Bolds nepārādās vispār.

     

     

    Vai varētu būt vainīgs JS skripta novietojums dokumentā?

  2. Paldies!

     

    Ar HTML/CSS/PHP problēmu nav, bet JS tikpat kā nezinu vispār ;)

     

    Šis variants darbojas, bet sanāk, ka ja šie linki ir 12 gab, tad katram vajag iekš onClick rakstīt:

     

    document.GetElementBy(1).style.fontWeight = 'normal';

    document.GetElementBy(2).style.fontWeight = 'normal';

    document.GetElementBy(3).style.fontWeight = 'normal';

    ...

     

    tā lai pārējie nebūtu bold. Vai ir kāds īsāks variants? Varbūt, ja var ar this.style noteikt stilu konkrētajam linkam, tad ar xxxx.style var arī iepriekšējam nospiestajam? :)

     

    Protams, var pie katra no 12 linkiem iekopēt vēl 12 rindiņas un viss tāpat darbosies.

  3. Paldies, andrisp, bet vai vari lūdzu parādīt piemēro šajā kodā? vai man katrs no pārējiem būtu kaut kā jānosauc un tad jānorāda uz katru kuram jānoņem bold? Kā jau teicu, JS man tumša bilde ;)

     

    <script type="text/javascript">
    var teksti = ['teksts1','teksts2','teksts3','teksts4','teksts5'];
    </script>
    
    <div id="tekstiem"></div>
    
    <a href="#" onclick="document.getElementById('tekstiem').innerHTML = teksti[0]; this.style.fontWeight = 'bold'; return false;">1</a>
    <a href="#" onclick="document.getElementById('tekstiem').innerHTML = teksti[1]; this.style.fontWeight = 'bold'; return false;">2</a>
    <a href="#" onclick="document.getElementById('tekstiem').innerHTML = teksti[2]; this.style.fontWeight = 'bold'; return false;">3</a>
    <a href="#" onclick="document.getElementById('tekstiem').innerHTML = teksti[3]; this.style.fontWeight = 'bold'; return false;">4</a>
    <a href="#" onclick="document.getElementById('tekstiem').innerHTML = teksti[4]; this.style.fontWeight = 'bold'; return false;">5</a>

  4. Sveiki!

     

    JS man ir tumša bilde. Iedomājos, ka jūs varētu palīdzēt.

     

    Lieta tāda:

     

    Ir <div></div> , kurā jāparādās kādam nelielam tekstam. Kopā teksta gabalini varētu būt kādi 10. Turpat iekš <div>'a ir linki: 1 - 2 - 3 - ...... 10 uz kuriem nospiežot, augstak parādās teksts.

     

    Tātad būtu masīvs ar 10 tekstiņiem, un pēc linka nospiešanas attiecīgajam jāparādās.

     

    Vai kāds lūdzu varētu iedot piemēru?

     

     

    Paldies.

×
×
  • Create New...