Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2003
    Messaggi
    152

    Come rendere hidden/visible + input ?

    Salve , ho un form , creato in php che puo' avere diversi campi che io voglio far passare da nascosti a visibili tutti con un click (checkbox o simili) .
    I vari input da rendere visibili possono avere o stesso id , name , o nomeid1 , nomeid2 ecc ecc ..
    Ho cercato in giro ,ma son riuscito a trovare solo son javascript che rendono visibilie 1 campo alla volta .
    Sapreste darmi un mano ???
    Vi pregooo !!
    non so

  2. #2
    Utente di HTML.it
    Registrato dal
    Jan 2003
    Messaggi
    152
    preciso che i vari hidden non possono stare tutti all'interno di un singolo <div > .
    usando i vari js che ho trovato , funzionano perfettametne se il div è uno solo .
    Nel caso in cui i div siano 2 , anche con lo stesso nome , solo 1 appare/scompare !!
    non so

  3. #3
    Utente di HTML.it
    Registrato dal
    Jan 2003
    Messaggi
    152
    Se a qualcuno interessasse , + avant , ho risolto .
    Posto una pag di esempio , con 2 input soltanto . i vari input da rendere vi/invis , basta metterli nell'array:

    codice:
    <html>
    <head>
    <title>untitled</title>
    
    <script language="JavaScript" type="text/javascript">
    
    //the layer ids conveniently collected
    var layerIDs = new Array('descr1','descr2','descr3','descr4','descr5','descr6'); 
    
    //where's the layer at? (depends on browser)
    function getLayer(id) { 
    var l = document.getElementById ? document.getElementById(id) : 
    document.all ? document.all[id] : 
    document.layers ? document[id] : null; 
    return l; 
    } 
    
    function toggleAll() { 
    var currLayer; 
    for (var i=0; i<layerIDs.length; i++) { //run through the ids
    currLayer = getLayer(layerIDs[i]); //plug in id to get ref to each layer 
    if (currLayer) { //does it exist?
    if (document.layers) { //NS4
    currLayer.visibility = (currLayer.visibility == 'show') ? 'hide' : 'show'; //check visibility & toggle
    } else { //good browsers
    currLayer.style.visibility = ((currLayer.style.visibility == 'visible') ? 'hidden' : 'visible'); //ditto
    } 
    } 
    } 
    }
    
    </script>
    </head>
    <body>
    HIDE 'EM / SHOW 'EM
    <div id="descr1" style="visibility:hidden;"><input name="description[$x]" type="text" value=""></div>
    <div id="descr4" style="visibility:hidden;"><input name="description[$x]" type="text" value=""></div>
    </body>
    </html>
    non so

  4. #4
    Ciao a tutti,
    stò cercando di utilizzare questo script:

    <script type="text/javascript" language="javascript">
    function toggleBox(id){if(!document.getElementById) return; var box = document.getElementById(id);
    if(box.className = 'box_hidden') box.className = 'box_visible';
    else box.className = 'box_hidden'; }
    </script>

    che si collega a questo css:

    <style type="text/css" >
    body {
    font: 11px sans-serif;
    color:#FFFFFF;
    background-color: #000000;
    }
    .boxhead {width:740px; padding:2px 10px; background-color: #666666; border:1px solid #666; margin-bottom:0; cursor: pointer; font-weight:bold; }
    .box_visible {width:740px; padding:5px 10px; border:1px solid #666; margin-top:0; }
    .box_hidden {display: none;}
    </style>

    che ha poi il richiamo nel body:

    <p onclick="toggleBox('box1')" class="boxhead">Box 1</p>
    <p id="box1" class="box_visible">CONTENUTO</p>

    <p onclick="toggleBox('box2')" class="boxhead">Box 2</p>
    <p id="box2" class="box_visible">CONTENUTO</p>

    Ovviamente non funziona...
    qualcuno mi sa dire dove sbaglio???

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.