Hola a todos!
necesito hacer un contador de visitas en la página principal, pero que las muestre en numeros romanos, ¿Alguien tiene una función o sabe como hacerlo?
gracias de antemano!
| |||
contador en nº romanos Hola a todos! necesito hacer un contador de visitas en la página principal, pero que las muestre en numeros romanos, ¿Alguien tiene una función o sabe como hacerlo? gracias de antemano!
__________________ -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- Publicado por: portillo18 -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- |
| ||||
Respuesta: contador en nº romanos del 1 al 9 I,II,III,IV,V,VI,VII,VIII,IX de 10 en 10 X,XX,XXX,XL,LX,LXX,LXXX,XC de cien en cien C,CC,CCC,CD,D,DC,DCC,DCCC,CM los resultados intermedios es una combinacion de todas, para que mires una pagina con ejemplos de numeros, ENTRA EN ESTA PAGINA, al parece el rango maximo en esa pagina es MMMDCCCXCIX = 3899 Utilizan este Javascript <--- con derechos de autor --- ![]() Cita: pero mirando detenidamente es algo sencillo, convertirlo a funcion de ASP<script language="javascript1.1"><!-- // copyright 2002 24 Hour Translations. You may ask for permission to use this script (or a modified version) // by contactin the webmaster at webmaster@24hourtranslations.co.uk with details of the site it is to be placed on. // generally, this will require that you ensure that the following html link is visible and placed directly below the conversion box: // <a href="http://www.24HourTranslations.co.uk/">Get an English to Latin Translation by a professional English to Latin Translator</a> function fix(thenumber,noplaces){ var oldnumber=thenumber; thenumber=thenumber+"00000 "; var decpos=thenumber.indexOf("."); if (decpos==-1) return oldnumber; decpos=decpos+noplaces+1; if (noplaces==0) decpos=decpos-1; var endstring=thenumber.substring(0,decpos); return endstring; } function ConvertNumber(){ // convert into Roman numerals var array_thousands=new Array("","M","MM","MMM"); var array_hundreds=new Array("","C","CC","CCC","CD","D","DC","DCC","DCCC" ,"CM"); var array_tens=new Array("","X","XX","XXX","XL","L","LX","LXX","LXXX" ,"XC"); var array_ones=new Array("","I","II","III","IV","V","VI","VII","VIII" ,"IX"); var ones,tens,hundreds,thousands,number; number=document.converter.number.value; if (!(number<3900) || !(number>0)) { document.converter.numeral.value="Out of Range"; return false; } ones=number%10; tens=number%100-ones; hundreds=number%1000-(tens+ones); thousands=number-(hundreds+tens+ones); document.converter.numeral.value=array_thousands[thousands/1000]+array_hundreds[hundreds/100]+array_tens[tens/10]+array_ones[ones]; } function ConvertNumeral(){ // convert into number var array_thousands=new Array("","M","MM","MMM"); var array_hundreds=new Array("","C","CC","CCC","CD","D","DC","DCC","DCCC" ,"CM"); var array_tens=new Array("","X","XX","XXX","XL","L","LX","LXX","LXXX" ,"XC"); var array_ones=new Array("","I","II","III","IV","V","VI","VII","VIII" ,"IX"); var ones=0; var tens=0; var hundreds=0; var thousands=0; var numeral=document.converter.numeral.value+""; numeral=numeral.toUpperCase(); var current=0; var width=0; var number=0; for (number=1; number<4; number++){ // check thousands if (numeral.indexOf(array_thousands[number],current)==0){ thousands=number; width=array_thousands[number].length; } } current=current+width; width=0; for (number=1; number<10; number++){ // check hundreds if (numeral.indexOf(array_hundreds[number],current)==current){ hundreds=number; width=array_hundreds[number].length; } } current=current+width; width=0; for (number=1; number<10; number++){ // check tens if (numeral.indexOf(array_tens[number],current)==current){ tens=number; width=array_tens[number].length; } } current=current+width; width=0; for (number=1; number<10; number++){ // check ones if (numeral.indexOf(array_ones[number],current)==current){ ones=number; width=array_ones[number].length; } } current=current+width; document.converter.number.value=thousands*1000+hun dreds*100+tens*10+ones; if (current!=numeral.length) document.converter.number.value="Out of Range"; return; } --></script> un poco de paciencia y una dotacion de Coca(liquida ehh ![]() ![]() p.d. esta otra pagina te puede dar numero mayores que la anterior
__________________ "Eres parte del problema, parte de la solucion o parte del paisaje" Un Saludo desde Desierto de Altar, Sonora, MX. Shiryu_libra Última edición por Shiryu_Libra; 11/06/2008 a las 07:42 |
| |||
Respuesta: contador en nº romanos Muxas gracias Shiryu_Libra! Ya consegui sacar lo que queria :) bueno por si a alguien le interesa digo el procedimiento: En el head pongo el siguiente script: Cita: En el onload del body : onload="romanise();"<script> function romanise(){ var persian=numeral.value; var roman=""; var ronumdashes=""; var buffer=10-persian.length; while (buffer>0) {persian="0"+persian;buffer--} var units=new Array("","I","II","III","IV","V","VI","VII","VIII" ,"IX"); var tens=new Array("","X","XX","XXX","XL","L","LX","LXX","LXXX" ,"XC"); var hundreds=new Array("","C","CC","CCC","CD","D","DC","DCC","DCCC" ,"CM"); var thousands=new Array("","M","MM","MMM","MV","V","VM","VMM","VMMM" ,"MX"); var billionsdashes=new Array("","=","==","===","==","=","==","===","====" ,"=="); romandashes=billionsdashes[persian.substring(0,1)]; var hundredmillionsdashes=new Array("","=","==","===","==","=","==","===","====" ,"=="); romandashes+=hundredmillionsdashes[persian.substring(1,2)]; var tenmillionsdashes=new Array("","=","==","===","==","=","==","===","====" ,"=="); romandashes+=tenmillionsdashes[persian.substring(2,3)]; var millionsdashes=new Array("","_","__","___","_=","=","=_","=__","=___" ,"_="); romandashes+=millionsdashes[persian.substring(3,4)]; var hundredthousandsdashes=new Array("","_","__","___","__","_","__","___","____" ,"__"); romandashes+=hundredthousandsdashes[persian.substring(4,5)]; var tenthousandsdashes=new Array("","_","__","___","__","_","__","___","____" ,"__"); romandashes+=tenthousandsdashes[persian.substring(5,6)]; var thousandsdashes=new Array("","","",""," _","_","_","_","_"," _"); romandashes+=thousandsdashes[persian.substring(6,7)]; roman=thousands[persian.substring(0,1)]; roman+=hundreds[persian.substring(1,2)]; roman+=tens[persian.substring(2,3)]; roman+=thousands[persian.substring(3,4)]; roman+=hundreds[persian.substring(4,5)]; roman+=tens[persian.substring(5,6)]; roman+=thousands[persian.substring(6,7)]; roman+=hundreds[persian.substring(7,8)]; roman+=tens[persian.substring(8,9)]; roman+=units[persian.substring(9,10)]; //este br iria romandashes+"<br>"+roman; result.innerHTML=romandashes+roman; } </script> Dentro del body creo una carpeta para contar visitas y el nº de visita lo pasar en la funcion romanise() a numeros romanos: Cita: <% on error resume next ' Create a server object set fso = createobject("scripting.filesystemobject") ' Target the text file to be opened set act = fso.opentextfile(server.mappath("Contador.txt")) ' Read the value of the text document ' If the text document does not exist then the on error resume next ' will drop down to the next line counter = clng(act.readline) ' Add one to the counter counter = counter + 1 ' Close the object act.close ' Create a new text file on the server Set act = fso.CreateTextFile(server.mappath("Contador.txt"), true) ' Write the current counter value to the text document act.WriteLine(counter) ' Close the object act.Close ' Write the counter to the browser as text 'Response.Write "" & counter %> <input type="hidden" value=<%=counter%> name=numeral size="10" onKeypress="if (event.keyCode<48 || event.keyCode>57) event.returnValue=false;" maxlength="10"> Por ultimo muestro las visitas en nº romanos: Cita: <font color="#CC0033" face="Geneva, Arial, Helvetica, sans-serif, Rockwell"><tt id=result style=font-size:10pt></tt></font> Espero que a alguien le sirva de ayuda! A mi me funcionó a la perfección. Saludos
__________________ -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- Publicado por: portillo18 -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- |
| |||
Respuesta: Problema con contador Buenas de nuevo!me ha vuelto a surgir un problema: Como mencione antes todo me sale correcto o casi. Con el código que puse antes al hacer un refresh me aumentaba el contador, lo que me piden ahora es que mientras este el explorador abierto no me aumente el contador por mucho que reinicie, pero si cierro el explorador y nuevamente lo abro otra vez y entro en la página me vuelva a aumentar las visitas. Espero que me haya expresado bien. Es urgente porfavor! Gracias
__________________ -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- Publicado por: portillo18 -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- |