Visualizzazione dei risultati da 1 a 4 su 4

Discussione: Explorer ed il DOM

  1. #1

    Explorer ed il DOM

    Ciao a tutti,
    In una form che ho redatto ho descritto dei chek-bottom che una volta premuti trasfriscono il fuoco a dei campi testo a fianco.

    Per fare ciò ho usato il DOM con l'espressione: document.nome_form.nome_campo.focus().

    Il problema e che questa espressione funziona, purtroppo, solo con netscape e similari ma non con explorer, eppure anche quest'ultimo dovrebbe essere compatibile col DOM.

    Ho fatto qualche errore o questo sistema non è quello giusto?

    - Grazie -

    --
    Bye by AFo

  2. #2
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    suona strano, è corretto ed in genere è IE a digerire anche i sassi

    puoi postare form e funzioni richiamate così ci togliamo subito qualche dubbio?

    un alert(document.nomeForm.nomeCampo.value) fila liscio?

  3. #3
    Ti posto volentieri il listato (si tratta di un file html con i javascript interni)

    eccolo:

    ------------------------------------------------------------

    <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="GENERATOR" content="Quanta+ HTML Editor v.2.00 (X11; U; Linux 2.2.16 i586)">
    <meta name="Author" content="Beginners' Club">
    <meta name="Description" content="Official site / Sito ufficiale">
    <title>Equipe vitesse</title>
    </head>
    <body text="black" bgcolor="white">
    <script language="JavaScript">
    <!--

    function fuoco1(){
    document.scheda.t_giacca.focus();
    }

    function fuoco2(){
    document.scheda.t_tshirt.focus();
    }

    function fuoco3(){
    document.scheda.t_polo.focus();
    }

    function fuoco4(){
    document.scheda.t_camicia.focus();
    }

    function fuoco5(){
    document.scheda.t_smanicato.focus();
    }

    function fuoco6(){
    document.scheda.t_felpa.focus();
    }

    function fuoco7(){
    document.scheda.t_cappel.focus();
    }

    -->
    </script>
    <table width=650>
    <tr>
    <td>
    <hr>
    </td>
    </tr>
    </table>
    Taglie abbigliamento sociale della scuderia


    <table width="650" border="0">
    <tr>
    <td width="33%" align="left">
    <table width="90%" border="0">
    <tr>
    <td width="10%" align="left" height="50">
    <input type="checkbox" name="giacca" onchange="javascript:fuoco1()">
    </td>
    <td width="80%" align="left">
    Giacca a vento
    </td>
    <td width="10%" align="right">
    <input type="text" name="t_giacca" size=5>
    </td>
    </tr>
    </table>
    </td>
    <td width="33%" align="center">
    <table width="90%" border="0">
    <tr>
    <td width="10%" align="left" height="50">
    <input type="checkbox" name="t-shirt" onchange="javascript:fuoco2()">
    </td>
    <td width="80%" align="left">
    T-shirt
    </td>
    <td width="10%" align="right">
    <input type="text" name="t_tshirt" size=5>
    </td>
    </tr>
    </table>
    </td>
    <td width="33%" align="right">
    <table width="90%" border="0">
    <tr>
    <td width="10%" align="left" height="50">
    <input type="checkbox" name="polo" onchange="javascript:fuoco3()">
    </td>
    <td width="80%" align="left">
    Polo
    </td>
    <td width="10%" align="right">
    <input type="text" name="t_polo" size=5>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td width="33%" align="left">
    <table width="90%" border="0">
    <tr>
    <td width="10%" align="left" height="50">
    <input type="checkbox" name="camicia" onchange="javascript:fuoco4()">
    </td>
    <td width="80%" align="left">
    Camicia
    </td>
    <td width="10%" align="right">
    <input type="text" name="t_camicia" size=5>
    </td>
    </tr>
    </table>
    </td>
    <td width="33%" align="center">
    <table width="90%" border="0">
    <tr>
    <td width="10%" align="left" height="50">
    <input type="checkbox" name="smanicato" onchange="javascript:fuoco5()">
    </td>
    <td width="80%" align="left">
    Smanicato
    </td>
    <td width="10%" align="right">
    <input type="text" name="t_smanicato" size=5>
    </td>
    </tr>
    </table>
    </td>
    <td width="33%" align="right">
    <table width="90%" border="0">
    <tr>
    <td width="10%" align="left" height="50">
    <input type="checkbox" name="felpa" onchange="javascript:fuoco6()">
    </td>
    <td width="80%" align="left">
    Felpa
    </td>
    <td width="10%" align="right">
    <input type="text" name="t_felpa" size=5>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td width="33%" align="left">
    </td>
    <td width="33%" align="center">
    <table width="90%" border="0">
    <tr>
    <td width="10%" align="left" height="50">
    <input type="checkbox" name="cappel" onchange="javascript:fuoco7()">
    </td>
    <td width="80%" align="left">
    Cappellino
    </td>
    <td width="10%" align="right">
    <input type="text" name="t_cappel" size=5>
    </td>
    </tr>
    </table>
    </td>
    <td width="33%" align="right">
    </td>
    </tr>
    </table>
    <font color="red" face="Verdana, Arial, Helvetica, sans-serif" size="-2">
    SCEGLIERE GLI ARTICOLI DESIDERATI ED INSERIRE NELLA CASELLA A FIANCO LA TAGLIA.
    </font>
    </div>
    </form>
    </body>
    </html>

    -----------------------------------------------------------

    L'ho dovuto decurtare per poterlo postare.

    Ho provato anche a non mettere il comando all'interno di una funzione ma direttamente nel "onchange" ma il risultato è uguale.
    --
    Bye by AFo

  4. #4
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    mi sembra che il problema non sia il riferimento all' elemento corretto
    ma che le istruzioni vengano richiamate onchange
    (gestore evento che dovrebbe essere valido solo x text, textarea, file e select)

    puoi usare l' onclick
    x es. se vuoi che il focus venga dato al campo solo se c' è il segno di spunta sul relativo checkbox puoi fare così
    codice:
    <script type="text/javascript">
    function fuoco(ckb){
      if(ckb.checked){
        document.nomeForm.elements['t_'+ckb.name].focus();
      }
    }
    </script>
    da richiamare con
    <input type="checkbox" name="felpa" onclick="fuoco(this);" />

    ciao

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.