Visualizzazione dei risultati da 1 a 3 su 3

Discussione: Script sposta testo

  1. #1

    Script sposta testo

    Ciao a tutti, ho realizzato uno script che dovrebbe spostare il testo da una casella ad un altra se presente, ma non funziona.
    codice:
    <html>
    <head>
    <title>Programma</title>
    </head>
    <body>
    <form>
    <fieldset>
    <legend>Sposta testo</legend>
    <input type="text" name="casella">
    <input type="text" name="casella2">
    <input type="button" value="Sposta il testo" onclick="sposta()">
    </fieldset>
    </form>
    </body>
    <script>
    function sposta()
    {
    var stringa = casella 2.value;
    if(casella.value.length > 0)
    {
    stringa = document.casella2.value;
    document.casella2.value = document.casella.value;
    }
    if(stringa.length > 0)
    {
    document.casella.value = stringa;
    }
    }
    </script>
    </html>
    chi mi aiuta?
    Ultima modifica di wormd; 02-02-2014 a 16:42
    ?

  2. #2
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    codice:
    <html>
    <head>
    <title>Programma</title>
    
    <script>
    function sposta()
    {
    if(document.modulo.casella.value.length >0){
    document.modulo.casella2.value =document.modulo.casella.value;
    }else{
    document.modulo.casella.value =document.modulo.casella2.value;
    }
    }
    </script>
    </head>
    <body>
    <form name="modulo">
    <fieldset>
    <legend>Sposta testo</legend>
    <inputtype="text"name="casella">
    <inputtype="text"name="casella2">
    <inputtype="button"value="Sposta il testo"onclick="sposta()">
    </fieldset>
    </form>
    </body>
    </html>
    
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  3. #3

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.