Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Aiutatemi vi prego

    vi prego aiutatemi con questo javascript, è per mettere la password alle pagine, ma non so come modificarlo per mettere la password che voglio io!
    Come devo fare?

    Ecco qui:
    Psw con combinazione numerica
    Questa password si serve di una combinazione numerica (in questo caso "1234"), la quale puo' essere modifica a piacimento. E' necessario creare un file HTML con nome identico alla combinazione scelta (in questo caso: "1234.html").


    questo è il codice javascript:



    <HTML>
    <HEAD>

    <!-- Codice scaricato gratuitamente da HTML.it, il sito italiano sul Web publishing
    http://www.html.it -->

    <TITLE>Esempi Javascript: esempio pratico </TITLE>

    <SCRIPT language="JavaScript">

    <!-- Key-code script by Bart Jellema
    // You may use this script freely as long
    // as you credit me for it...
    var usermulcode=24
    // This is to validate the code. In this case
    // the code is 1234 so the mul = 1*2*3*4 = 24
    // Change this value for your own code
    // If your code is 2415 it will be
    // usermulcode = 40 (2*4*1*5)
    var code=0 // the entered code
    var mul=1 // the multiplied digits
    var digit=0 // number of digits entered so far
    var fails=0 // number of tries done

    function Enter_code(number)
    {

    code=code*10+number // Add the digit to the code
    mul=mul*number // Update mul-value
    document.codepad.thecode.value=code // Show code
    digit++ // Increase digit

    if (digit==4) // Four digits entered
    {
    if (mul==24) // This is to validate
    // the code. In this case
    // the code is 1234 so the
    // mul = 1*2*3*4 = 24
    // Change this value for
    // your own code
    {
    location=code+".html"
    }
    else
    {
    fails++ // Increase fails
    code=0 // Reset values
    mul=1
    digit=0
    if (fails<3)
    {
    if (fails==1)
    {document.codepad.thecode.value="riprova"}
    if (fails==2)
    {document.codepad.thecode.value="ultima volta"}
    }
    else // To many tries = worp back
    {
    location="java.htm"
    document.codepad.thecode.value="A presto!"
    }
    }
    }
    }

    function keycodepad(mulcode)
    {
    usermulcode=mulcode
    document.write("<form name=\"codepad\">");
    document.write("<input type=\"button\" value=\" 1 \" onClick=\"Enter_code(1)\">");
    document.write("<input type=\"button\" value=\" 2 \" onClick=\"Enter_code(2)\">");
    document.write("<input type=\"button\" value=\" 3 \" onClick=\"Enter_code(3)\">
    ");
    document.write("<input type=\"button\" value=\" 4 \" onClick=\"Enter_code(4)\">");
    document.write("<input type=\"button\" value=\" 5 \" onClick=\"Enter_code(5)\">");
    document.write("<input type=\"button\" value=\" 6 \" onClick=\"Enter_code(6)\">
    ");
    document.write("<input type=\"button\" value=\" 7 \" onClick=\"Enter_code(7)\">");
    document.write("<input type=\"button\" value=\" 8 \" onClick=\"Enter_code(8)\">");
    document.write("<input type=\"button\" value=\" 9 \" onClick=\"Enter_code(9)\">
    ");
    document.write("<input type=\"text\" name=\"thecode\" size=10 value=\"\">
    ");
    document.write("</form>");
    }
    // Key-code script by Bart Jellema -->

    </SCRIPT>




    </HEAD>

    <BODY bgcolor="white" >



    <FORM name="codepad"><INPUT type="button" value=" 1 " onClick="Enter_code(1)"><INPUT type="button" value=" 2 " onClick="Enter_code(2)"><INPUT type="button" value=" 3 " onClick="Enter_code(3)">
    <INPUT type="button" value=" 4 " onClick="Enter_code(4)"><INPUT type="button" value=" 5 " onClick="Enter_code(5)"><INPUT type="button" value=" 6 " onClick="Enter_code(6)">
    <INPUT type="button" value=" 7 " onClick="Enter_code(7)"><INPUT type="button" value=" 8 " onClick="Enter_code(8)"><INPUT type="button" value=" 9 " onClick="Enter_code(9)">
    <INPUT type="text" name="thecode" size=10 value="">
    </FORM>


    </body>
    </html>


  2. #2
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    i controlli che fa il codice sono 2
    if (digit==4) // dev' essere 4 cifre
    if (mul==24) // il prodotto delle 4 cifre dev' essere 24

    qualsiasi prodotto di 4 cifre che dia 24 è valido (3412 x es.)
    poi si tratta di vedere se è esiste la pagina
    1234.htm va bene perchè esiste,
    3412.htm non trova la pagina

    prova mul=840, la pagina da proteggere è 4567.htm
    ciao

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