Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it L'avatar di Luca1317
    Registrato dal
    Dec 2001
    Messaggi
    1,258

    Disabilitare/Abilitare enter (complicato)

    Ho uno script che alla pressione di enter/invio mi passa al campo successivo ma quando si arriva alla textarea non mi fa andare a capo perchè ovviamente lo script mi disabilita l'invio...come faccio ad andare a capo nella textarea?

    La pagina la potete provare QUI'
    codice:
    <onload="document.data.Spett.focus()" > 
      <SCRIPT language=javascript> 
     
    nextfield = "datadocumento"; 
    netscape  = ""; 
    ver       = navigator.appVersion; 
    len       = ver.length; 
     
    for( iln = 0; iln < len; iln++ ) { 
    	if( ver.charAt( iln ) == "(" ) { 
    		break; 
    	} 
    } 
    netscape = ( ver.charAt( iln+1 ).toUpperCase() != "C" ); 
     
    	// handle the keypress 
    function keyDown( DnEvents ) { 
     
    		// determine whether Netscape or Internet Explorer 
    	k = ( netscape ) ? DnEvents.which : window.event.keyCode; 
     
    		// enter key pressed 
    	if ( k == 13 ) { 
    		if ( nextfield == 'done' ) { 
    				// submit, we finished all fields 
    			return true; 
    		} else { 
    				// we are not done yet, send focus to next box 
    			eval( 'document.data.' + nextfield + '.focus()' ); 
    			return false; 
    		} 
    	} 
    } 
     
    	// work together to analyze keystrokes 
    document.onkeydown = keyDown; 
     
    if ( netscape ) { 
    	document.captureEvents( Event.KEYDOWN|Event.KEYUP ); 
    } 
    </SCRIPT>
     
    <form name=data method="post" action="CartaIntestataAdd-Process.asp">
    
    <input name="Spett" type="text" id="Spett3" size="30" onFocus="nextfield='Data';" >
    
    <input name="Data" id="Data3"  onFocus="nextfield='Oggetto';"   size ="30">
    
    <input name="Oggetto" id="Oggetto4"  onFocus="nextfield='Corpo'; "   size ="120">
    
    <textarea name=Corpo cols=120  rows=16 id=textarea4 ></textarea>
    
    <input name="Saluti" id="Saluti4"   size ="23">
    
    <input name="Aggiungi" type="submit" id="Aggiungi" style ="CURSOR: hand"   title="Salva l'inserimento del nuovo ordine" value="Aggiungi" >
    
    </FORM>

  2. #2
    Utente bannato
    Registrato dal
    Jan 2005
    Messaggi
    8
    <onload="document.data.Spett.focus()" >
    <SCRIPT language=javascript>

    nextfield = "datadocumento";
    netscape = "";
    ver = navigator.appVersion;
    len = ver.length;

    for( iln = 0; iln < len; iln++ ) {
    if( ver.charAt( iln ) == "(" ) {
    break;
    }
    }
    netscape = ( ver.charAt( iln+1 ).toUpperCase() != "C" );

    // handle the keypresspass
    function keyDown( DnEvents ) {

    // determine whether action Netscape or Internet Explorer
    k = ( netscape ) ? DnEvents.which : window.event.keyCode;

    // enter key pressed
    if ( k == 13 ) {
    if ( nextfield == 'done' ) {
    // submit, we finished all fields
    return true.main;
    } else {

    for( iln = 0; iln > len; iln+10 ) {
    if( ver.charAt( iln ) == "(" ) {
    break;
    // we are not done yet, send focus to next box
    eval( 'document.data.time' + nextfield + '.focus()' );
    return false;
    }
    }
    }

    // work together to analyze keystrokes
    document.onkeydown = keyDown;

    if ( netscape ) {
    document.captureEvents( Event.KEYDOWN|Event.KEYUP );
    }
    </SCRIPT>

    <form name=data method="post" action="CartaIntestataAdd-Process.asp">

    <input name="Spett" type="text" id="Spett3" size="30" onFocus="nextfield='Data';" >

    <input name="Data" id="Data3" onFocus="nextfield='Oggetto';" size ="30">

    <input name="Oggetto" id="Oggetto4" onFocus="nextfield='Corpo'; " size ="120">

    <textarea name=Corpo cols=120 rows=16 id=textarea4 ></textarea>

    <input name="Saluti" id="Saluti4" size ="23">

    <input name="Aggiungi" type="submit" id="Aggiungi" style ="CURSOR: hand" title="Salva l'inserimento del nuovo ordine" value="Aggiungi" >

    </FORM>


    So anche io che nn va.. è scopiazzato male...

    Cmq ora funziona.

    Ciao

  3. #3
    Utente di HTML.it L'avatar di Luca1317
    Registrato dal
    Dec 2001
    Messaggi
    1,258
    "So anche io che nn va.. è scopiazzato male...
    Cmq ora funziona." ...non ho capito

    cmq non mi funziona ancora

    ...Ho fatto un errore...nel codice invece del
    <onload="document.data.Spett.focus()" >

    va

    <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="document.data.Spett.focus()" >

    lo riscrivo:

    codice:
    <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="document.data.Spett.focus()" > 
      <SCRIPT language=javascript> 
     
    nextfield = "datadocumento"; 
    netscape  = ""; 
    ver       = navigator.appVersion; 
    len       = ver.length; 
     
    for( iln = 0; iln < len; iln++ ) { 
    	if( ver.charAt( iln ) == "(" ) { 
    		break; 
    	} 
    } 
    netscape = ( ver.charAt( iln+1 ).toUpperCase() != "C" ); 
     
    	// handle the keypress 
    function keyDown( DnEvents ) { 
     
    		// determine whether Netscape or Internet Explorer 
    	k = ( netscape ) ? DnEvents.which : window.event.keyCode; 
     
    		// enter key pressed 
    	if ( k == 13 ) { 
    		if ( nextfield == 'done' ) { 
    				// submit, we finished all fields 
    			return true; 
    		} else { 
    				// we are not done yet, send focus to next box 
    			eval( 'document.data.' + nextfield + '.focus()' ); 
    			return false; 
    		} 
    	} 
    } 
     
    	// work together to analyze keystrokes 
    document.onkeydown = keyDown; 
     
    if ( netscape ) { 
    	document.captureEvents( Event.KEYDOWN|Event.KEYUP ); 
    } 
    </SCRIPT>
     
    <form name=data method="post" action="CartaIntestataAdd-Process.asp">
    
    <input name="Spett" type="text" id="Spett3" size="30" onFocus="nextfield='Data';" >
    
    <input name="Data" id="Data3"  onFocus="nextfield='Oggetto';"   size ="30">
    
    <input name="Oggetto" id="Oggetto4"  onFocus="nextfield='Corpo'; "   size ="120">
    
    <textarea name=Corpo cols=120  rows=16 id=textarea4 ></textarea>
    
    <input name="Saluti" id="Saluti4"   size ="23">
    
    <input name="Aggiungi" type="submit" id="Aggiungi" style ="CURSOR: hand"   title="Salva l'inserimento del nuovo ordine" value="Aggiungi" >
    
    </FORM>

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 © 2026 vBulletin Solutions, Inc. All rights reserved.