Ciao a tutti,
devo trovare data e sesso di un "utente" dal suo codice fiscale. Esiste qualcosa in JavaScript per far questo?
Grazie![]()
Ciao a tutti,
devo trovare data e sesso di un "utente" dal suo codice fiscale. Esiste qualcosa in JavaScript per far questo?
Grazie![]()
Cosa hai provato a fare finora?
i dati sul sesso e data di nascita sono contenuti nella sottostringa (6,10) : xxxxxx00x00x000x
quindi data una stringa cf contenente il codice fiscale
1) ricavi la sottostringa 6,10 ottenendo una stringa lunga 5 (00x00)
2) le prime due cifre sono l'anno di nascita. ma considera che se l'anno è compreso tra 0 e 12 l'anno potrebbe essere tanto 1900 quanto 2000
3) il terzo carattere rappresenta il mese secondo lo schema spiegato qui: http://it.wikipedia.org/wiki/Codice_fiscale
4) le ultime due cifre sono il giorno di nascita: se è maggiore di 40 significa che si tratta di una persona di sesso femminile (e devi sottrarre quindi 40 per ottenere il giorno di nascita), maschile altrimenti.
Vuoi aiutare la riforestazione responsabile?
Iscriviti a Ecologi e inizia a rimuovere la tua impronta ecologica (30 alberi extra usando il referral)
Ciao!Si ho visto che per i dati che mi servono, devo prendere in considerazione le 5 cifre centrali del codice.
E' la prima volta che uso le funzioni ma sto usando vb non javascript, sono fuori sezione alla grande. Come posso spostare?
Ho fatto il form per passare alla funzione il cod_fisc
la funzione, in testa alla pagina, è la seguentecodice:<form name="dati" method="post" action="defalut.asp"> <input type="text" name="cod" /> <input type="submit" value="Estrapola" name="Estrapola"/> </form>
per poi provare a stampare l'elaborazione della funzione (che non stampa una mazza)codice:<% dim a if request.form("Estrapola") <> "" then function Estrapola(cod_fisc) cod_fisc=request.Form("cod") a=(mid(cod_fisc,7,5)) end function end if %>
codice:<% response.Write(Estrapola(cod_fisc)) %>
Come mai non stampa?E' giusto il mid in funzione?
![]()
Dentro la funzione.
Estrapola = a
Roby
www.creamweb.it [v. 3.0]
:: Script ASP!
:: Web directory gratuita!
:: Campioni del mondo!
la funzione quanti valori può "uscire"?
Ho calcolato giorno, mese, anno e sesso, in 4 variabili diverse ovviamente.
Come faccio a estrapolare le 4 variabili?
ho provato
Estrapola=giorno
Estrapola=mese
Estrapola=anno
Estrapola=sesso
ma mi non va, legge solo un valore.
grazie Roby
metti un separatore...
www.creamweb.it [v. 3.0]
:: Script ASP!
:: Web directory gratuita!
:: Campioni del mondo!
Separatore?![]()
Retifico la funzione va, mi restituisce i valori apparte il giorno (e il sesso che sono concatenati).
Praticamente faccio:
e mi da errore tipo non corrispondente..ma dovrebbero essere corrette le cifre riportate...a sapere come vederle...codice:gior=(mid(cod_fisc,10,2)) g=cint(gior)
questo è il codice, stampa solo MarzoMarzo...codice:<% dim a, anno, m, mese, g, giorno, sesso, gior if request.form("Estrapola") <> "" then function Estrapola(cod_fisc) cod_fisc=request.Form("cod") a=(mid(cod_fisc,7,2)) anno=cstr("19"+a) m=(mid(cod_fisc,9,1)) if m="A" then mese="Gennaio" end if if m="B" then mese="Febbraio" end if if m="C" then mese="Marzo" end if if m="D" then mese="Aprile" end if if m="E" then mese="Maggio" end if if m="F" then mese="Giugno" end if if m="G" then mese="Luglio" end if if m="H" then mese="Agosto" end if if m="I" then mese="Settembre" end if if m="L" then mese="Ottobre" end if if m="M" then mese="Novembre" end if if m="N" then mese="Dicembre" end if gior=(mid(cod_fisc,10,2)) g=cint(gior) if g>40 then sesso="F" g=cstr(g-40) if len(g)=1 then giorno="0"+g else giorno=g end if else sesso="M" if len(g)=1 then giorno="0"+g else giorno=g end if end if Estrapola=giorno Estrapola=sesso Estrapola=anno Estrapola=mese end function end if %>
risotto
shere it!!!codice:<% dim a, anno, m, mese, g, giorno, sesso, gior if request.form("Estrapola") <> "" then function Estrapola(cod_fisc) cod_fisc=UCASE(request.Form("cod")) a=(mid(cod_fisc,7,2)) anno=cstr("19"&a) m=(mid(cod_fisc,9,1)) if m="A" then mese="01" end if if m="B" then mese="02" end if if m="C" then mese="03" end if if m="D" then mese="04" end if if m="E" then mese="05" end if if m="H" then mese="06" end if if m="L" then mese="07" end if if m="M" then mese="08" end if if m="P" then mese="09" end if if m="R" then mese="10" end if if m="S" then mese="11" end if if m="T" then mese="12" end if gior=(mid(cod_fisc,10,2)) g=cint(gior) if g>40 then sesso="F" g=cstr(g-40) if len(g)=1 then giorno="0" & g else giorno=g end if else sesso="M" if len(g)=1 then giorno="0" & g else giorno=g end if end if Estrapola=giorno & "/" & mese & "/" & anno & "-" & sesso end function end if %>![]()
Originariamente inviato da Gio2011
risotto![]()
Mi hai fatto venir fame!!