Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Johnnys Mau

codigo carrega div

Recommended Posts

ai galera consegui esse codigo que esta fazendo exatamente oq eu precisava eu clico no checkbox e ele abre uma div, só que quando eu clico pra preencher o campo text box fexa a div alguem ai pode me ajudar?

 

 

 

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

   <style type="text/css" media="screen">
     .hide{
       display:none;
     }
   </style>

    <div id="tabs">
       <div id="nav">
         <p>Enviar para Mais amigos?<input type="radio" name="tab" value="pkfrom" class="div1" /></p>

        <!-- <p>Show Div 2:<input type="radio" name="tab" value="pkfrom" class="div2" /></p>   -->
       </div>

       <div id="div1" class="tab">
         <p>
          <div style="float: left; width: 140px; height: 28px; line-height: 28px; margin-top: 5px; ">Nome do meu amigo:</div>
            <div style="float: left; width: 440px; margin-top: 5px; ">
                 <input name="nome_recebeu2" value="<?echo $nome_recebeu2;?>" maxlength="50" style="width: 280px;" class="f-input-m" />
             </div>

              <div style="float: left; width: 140px; height: 28px; line-height: 28px; margin-top: 5px; ">E-Mail do meu amigo:</div>
              <div style="float: left; width: 440px; margin-top: 5px; ">
                <input name="email_recebeu2" value="<?echo $email_recebeu2;?>" maxlength="50" style="width: 280px;" class="f-input-m" />
              </div>


          <div style="float: left; width: 140px; height: 28px; line-height: 28px; margin-top: 5px; ">Nome do meu amigo:</div>
            <div style="float: left; width: 440px; margin-top: 5px; ">
                 <input name="nome_recebeu3" value="<?echo $nome_recebeu3;?>" maxlength="50" style="width: 280px;" class="f-input-m" />
             </div>

              <div style="float: left; width: 140px; height: 28px; line-height: 28px; margin-top: 5px; ">E-Mail do meu amigo:</div>
              <div style="float: left; width: 440px; margin-top: 5px; ">
                <input name="email_recebeu3" value="<?echo $email_recebeu3;?>" maxlength="50" style="width: 280px;" class="f-input-m" />
              </div>


          <div style="float: left; width: 140px; height: 28px; line-height: 28px; margin-top: 5px; ">Nome do meu amigo:</div>
            <div style="float: left; width: 440px; margin-top: 5px; ">
                 <input name="nome_recebeu4" value="<?echo $nome_recebeu4;?>" maxlength="50" style="width: 280px;" class="f-input-m" />
             </div>

              <div style="float: left; width: 140px; height: 28px; line-height: 28px; margin-top: 5px; ">E-Mail do meu amigo:</div>
              <div style="float: left; width: 440px; margin-top: 5px; ">
                <input name="email_recebeu4" value="<?echo $email_recebeu4;?>" maxlength="50" style="width: 280px;" class="f-input-m" />
              </div>


              <div style="float: left; width: 140px; height: 28px; line-height: 28px; margin-top: 5px; ">Nome do meu amigo:</div>
            <div style="float: left; width: 440px; margin-top: 5px; ">
                 <input name="nome_recebeu5" value="<?echo $nome_recebeu5;?>" maxlength="50" style="width: 280px;" class="f-input-m" />
             </div>

              <div style="float: left; width: 140px; height: 28px; line-height: 28px; margin-top: 5px; ">E-Mail do meu amigo:</div>
              <div style="float: left; width: 440px; margin-top: 5px; ">
                <input name="email_recebeu5" value="<?echo $email_recebeu5;?>" maxlength="50" style="width: 280px;" class="f-input-m" />
              </div>





         </p>
       </div>

     <div id="div2" class="tab">
         <p> </p>
       </div>
     </div>

     <script type="text/javascript" charset="utf-8">
       (function(){
         var tabs =document.getElementById('tabs');
         var nav = tabs.getElementsByTagName('input');

         /*
         * Hide all tabs
         */
         function hideTabs(){
           var tab = tabs.getElementsByTagName('div');
           for(var i=0;i<=nav.length;i++){
             if(tab[i].className == 'tab'){
               tab[i].className = tab[i].className + ' hide';
             }
           }
         }

         /*
         * Show the clicked tab
         */
         function showTab(tab){
           document.getElementById(tab).className = 'tab'
         }

         hideTabs(); /* hide tabs on load */

         /*
         * Add click events
         */
         for(var i=0;i<nav.length;i++){
           nav[i].onclick = function(){
             hideTabs();
             showTab(this.className);
           }
         }
       })();
     </script>

Compartilhar este post


Link para o post
Compartilhar em outros sites

faça uma condição:

 

for(var i=0;i<nav.length;i++){
   if( nav[i].type=='radio' )
   {
       nav[i].onclick = function(){

assim ele só aplica o click se o type do input for radio.

Dessa forma, os seus inputs text, não disparam o evento de esconder.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.