Ver Mensaje Individual
  #3 (permalink)  
Antiguo 11/06/2008, 08:28
portillo18
 
Fecha de Ingreso: abril-2008
Mensajes: 51
Antigüedad: 17 años, 6 meses
Puntos: 1
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:
<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>

En el onload del body : onload="romanise();"


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
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-