IT NEWS PC REVUE PC FORUM FreeBSDInternet time: @971
Obsah fóra
Pravidlá  •  Kontakt  •  Prihlásenie  •  Registrácia

Klávesy a piána CASIO, YAMAHA

Predaj klávesov a digitálnych pián. Výhodné ceny, doprava zdarma. www.casallia.sk

Webhosting - akcia +9 mesiacov

K ročnému predplatnému až 9 mesiacov zadarmo pri prevode hostingu k nám. www.exohosting.sk

10% Zľava+Darček - prvý nákup

Zvýhodnené 2-balenia krmív za babku V ponuke aj chovateľské doplnky www.petanimal.sk

Kedy sa oplatí prerobiť auto

na plyn? Nemusíte nevyhnutne hľadať kalkulačku a papier, aby ste si autoviny.zoznam.sk

Zákaznícka zóna Môj Orange

Pozrite si podrobný rozpis hovorov, spotrebu alebo si aktivujte služby. www.orange.sk

checkbox

Zaslať odpoveď
AutorSpráva
elo
Užívateľ
Užívateľ

Založený: 24.11.2009
Príspevky: 59

PríspevokZaslal: Ut 30.08.11 16:06Odpovedať s citátomNávrat hore

kód:
Nazov
<input type="checkbox" checked name="zaskrkavatko"><br>

<input type="text" size="10" name="popis"><br>

<br><br><br>


Nazov 2
<input type="checkbox" checked name="zaskrkavatko2"><br>

<input type="text" size="10" name="popis2">


ako prosím vyriesit po oznaceni checked sa zobrazi textove pole a inak je skryte?

d.
Zobraziť informácie o autoroviOdoslať súkromnú správu
camo
Zablokovaný užívateľ
Zablokovaný užívateľ

Založený: 05.09.2009
Príspevky: 1176
Bydlisko: Lehota pod Vtáčnikom

PríspevokZaslal: Ne 04.09.11 9:42Odpovedať s citátomNávrat hore

Naviazať na onchange toho checkboxu nejakú funkciu, ktorá zistí, či je zaškrtnutý, alebo nie a podľa toho nastaví viditeľnosť toho textového poľa.
Zobraziť informácie o autoroviOdoslať súkromnú správuSkypeZobraziť autorove WWW stránky
Ďuri
Administrátor
Administrátor

Založený: 11.08.2007
Príspevky: 3784
Bydlisko: Brno

PríspevokZaslal: Ne 04.09.11 10:29Odpovedať s citátomNávrat hore

Na checkbox sa zvykne navazovat udalost onclick, lebo v niektorych prehliadacoch sa udalost onchange vyvola az po odstraneni focusu. Funguje to inak ale rovnako, onclick reaguje aj na kliknutie mysi, aj na zmenu klavesnicou.
Zobraziť informácie o autoroviOdoslať súkromnú správuJabberSkype
elo
Užívateľ
Užívateľ

Založený: 24.11.2009
Príspevky: 59

PríspevokZaslal: Ut 11.10.11 20:17Odpovedať s citátomNávrat hore

kód:
 <script type="text/javascript">
document.getElementById('vm_dodaci_field').onclick = function(){
    if (document.getElementById('vm_dodaci_field').checked)
    {
      document.getElementById("company_field").style.visibility = "visible";
     document.getElementById("company_div").style.visibility = "visible";
     document.getElementById("address_1_field").style.visibility = "visible";
    document.getElementById("address_1_div").style.visibility = "visible";
     document.getElementById("city_field").style.visibility = "visible";
    document.getElementById("city_div").style.visibility = "visible";
     document.getElementById("zip_field").style.visibility = "visible";
    document.getElementById("zip_div").style.visibility = "visible";
     document.getElementById("phone_1_field").style.visibility = "visible";
    document.getElementById("phone_1_div").style.visibility = "visible";
     document.getElementById("phone_2_field").style.visibility = "visible";
    document.getElementById("phone_2_div").style.visibility = "visible";
    }
    else
    {
      document.getElementById("company_field").style.visibility = "hidden";
     document.getElementById("company_div").style.visibility = "hidden";
     document.getElementById("address_1_field").style.visibility = "hidden";
     document.getElementById("address_1_div").style.visibility = "hidden";
     document.getElementById("city_field").style.visibility = "hidden";
     document.getElementById("city_div").style.visibility = "hidden";
     document.getElementById("zip_field").style.visibility = "hidden";
     document.getElementById("zip_div").style.visibility = "hidden";
     document.getElementById("phone_1_field").style.visibility = "hidden";
     document.getElementById("phone_1_div").style.visibility = "hidden";
     document.getElementById("phone_2_field").style.visibility = "hidden";
     document.getElementById("phone_2_div").style.visibility = "hidden";
    }
  }
</script>

<style>
#company_field, #company_div,#address_1_field, #address_1_div, #city_field, #city_div,#zip_field, #zip_div,
#phone_1_field, #phone_1_div, #phone_2_field, #phone_2_div {visibility:hidden;};
</style>

 <script type="text/javascript">
document.getElementById('vm_fir_field').onclick = function(){
    if (document.getElementById('vm_fir_field').checked)
    {
      document.getElementById("vm_firmy_field").style.display = "block";
     document.getElementById("vm_firmy_div").style.display = "block";
     document.getElementById("vm_uliceb_field").style.display = "block";
    document.getElementById("vm_uliceb_div").style.display = "block";
     document.getElementById("vm_mestob_field").style.display = "block";
    document.getElementById("vm_mestob_div").style.display = "block";
     document.getElementById("vm_pscb_field").style.display = "block";
    document.getElementById("vm_pscb_div").style.display = "block";
     document.getElementById("vm_ico_field").style.display = "block";
    document.getElementById("vm_ico_div").style.display = "block";
     document.getElementById("vm_dic_field").style.display = "block";
    document.getElementById("vm_dic_div").style.display = "block";
     document.getElementById("vm_telfax_field").style.display = "block";
    document.getElementById("vm_telfax_div").style.display = "block";
     document.getElementById("vm_mobil_field").style.display = "block";
    document.getElementById("vm_mobil_div").style.display = "block";
    }
    else
    {
      document.getElementById("vm_firmy_field").style.display = "none";
     document.getElementById("vm_firmy_div").style.display = "none";
     document.getElementById("vm_uliceb_field").style.display = "none";
     document.getElementById("vm_uliceb_div").style.display = "none";
     document.getElementById("vm_mestob_field").style.display = "none";
     document.getElementById("vm_mestob_div").style.display = "none";
     document.getElementById("vm_pscb_field").style.display = "none";
     document.getElementById("vm_pscb_div").style.display = "none";
     document.getElementById("vm_ico_field").style.display = "none";
     document.getElementById("vm_ico_div").style.display = "none";
     document.getElementById("vm_dic_field").style.display = "none";
     document.getElementById("vm_dic_div").style.display = "none";
     document.getElementById("vm_telfax_field").style.display = "none";
     document.getElementById("vm_telfax_div").style.display = "none";
     document.getElementById("vm_mobil_field").style.display = "none";
     document.getElementById("vm_mobil_div").style.display = "none";
    }
  }
</script>
<style>
#vm_firmy_field, #vm_firmy_div,#vm_uliceb_field, #vm_uliceb_div, #vm_mestob_field, #vm_mestob_div,#vm_pscb_field, #vm_pscb_div,
#vm_ico_field, #vm_ico_div, #vm_dic_field, #vm_dic_div, #vm_telfax_field, #vm_telfax_div, #vm_mobil_field, #vm_mobil_div {display:none;};

</style>



Tento kod funguje avsak s jednou chybickou.

Ma velke medzery (vela volnych riadkov) medzie jednotlivymi checkboxmi.

Ako to mozem upravit?

Dakujem za pomoc.
Zobraziť informácie o autoroviOdoslať súkromnú správu
chrono
Skúsený užívateľ
Skúsený užívateľ

Založený: 13.11.2007
Príspevky: 808

PríspevokZaslal: Ut 11.10.11 21:21Odpovedať s citátomNávrat hore

Tie elementy sú pri sebe? Ak áno, tak ich daj napr. do div (prípadne, ešte lepšie do fieldset) a skry len ten jeden element.
Zobraziť informácie o autoroviOdoslať súkromnú správu
elo
Užívateľ
Užívateľ

Založený: 24.11.2009
Príspevky: 59

PríspevokZaslal: Ut 11.10.11 21:36Odpovedať s citátomNávrat hore

Mozete prosim napisat viac ako to vlozit a najma kde presne do kodu?

Dakujem.
Zobraziť informácie o autoroviOdoslať súkromnú správu
chrono
Skúsený užívateľ
Skúsený užívateľ

Založený: 13.11.2007
Príspevky: 808

PríspevokZaslal: Ut 11.10.11 22:03Odpovedať s citátomNávrat hore

Teraz je v html kóde niečo ako:
kód:
<input id="company_field">
<input id="company_div">
...
a v javascripte sa skrývajú jednotlivé elementy.

Rozumnejšie by ale mohlo byť (možno aj nie, záleží to od použitého html kódu), ak by sa tie elementy niečím obalili, takže by to mohlo vyzerať napr. takto
kód:
<div id="polozky">
    <input id="company_field">
    <input id="company_div">
    ...
</div>
a skryl/zobrazil by sa len ten obalovací element (v tomto prípade div, ak je to fo formulári, tak by sa mohol použiť fieldset).
Zobraziť informácie o autoroviOdoslať súkromnú správu
Zobraziť príspevky z predchádzajúcich:    
Zaslať odpoveď
Nemôžete pridávať nové témy do tohto fóra.
Nemôžete odpovedať na témy v tomto fóre.
Nemôžete upravovať svoje príspevky v tomto fóre.
Nemôžete mazať svoje príspevky v tomto fóre.
Nemôžete hlasovať v tomto fóre.

Powered by phpBB 2.x.x © 2005 - 2012 PCforum, webhosting by WebSupport, edited by JanoF

SEO - optimalizácia pre vyhľadávače

Freebsd