Tengo una simple calculadora o convertidora de medidas, de longitud y/o de peso. Funciona bien, pero queria aplicarle unos estilos, para que se vea bonita, y de hecho se ve muy bien usando Pretty Forms ([URL="http://www.agavegroup.com/agWork/prettyForms/"]ver aqui[/URL]).
Problema: Tan pronto cargo prettyforms.js
Código:
el estilo cambia, pero la funcionalidad de conversion de medidas se va. $(document).ready(function() { prettyForms() });
Usando Firebug veo el siguiente error:
Código:
Solo quiero que lo vean y me digan si es que no es posible que coexistan, mis conversiones y prettyforms. "U2 is not defined" "if ( U2.options[U2.selectedInd...tedIndex > -1 && isnum(V1.value) ) { "
Gracias!
Mi pagina con las conversiones:
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Conversiones</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> <link rel="stylesheet" href="herr/prettyforms/prettyForms.css" type="text/css" media="screen" /> <script type="text/javascript" src="herr/js/cargaprettyforms.js"></script> <script type="text/javascript" src="herr/prettyforms/prettyForms.js"></script> </head> <body> <SCRIPT language=Javascript> <!-- function calculate(obj, inform) { nfig = parseInt(document.getElementById('precision').value); nfig=(nfig==0)?6:nfig; with (inform) { if ( U2.options[U2.selectedIndex].value != 0 && U1.selectedIndex > -1 && isnum(V1.value) ) { V2.value=roundfig(eval(V1.value) * eval(U1.options[U1.selectedIndex].value) /eval(U2.options[U2.selectedIndex].value),nfig); } } } function isnum(num) { return (!isNaN(num)); if ( num == 0 ) { return true; } if ( num == "" ) { return false; } for (var i=0; i < num.length; i++) { var ch= num.substring (i, i+1) if ((ch < "0" || ch > "9" ) && ch != "." && (i>1 && ch =="-") ) { return false; } } return true; } function roundfig(num,nfig) { if(isnum(num)) { ndp = parseInt(-1 * Math.log(num)/Math.log(10)); ans = Math.round(num * Math.pow(10,ndp+nfig))/Math.pow(10,ndp+nfig); return ans; } } </SCRIPT> <TABLE width="430" BORDER=0 align="center"> <TR> <form name=lengthconv> <TD width="200" valign="top"><p><B>Conversion de Medidas</B> (Ingrese la medida)<BR> <input Width=20 name=V1 onChange="calculate(this,document.lengthconv)"> <select Width=60 onChange="calculate(this,document.lengthconv)" name=U1> <option value=304.8>piés <option value=25.4>pulgadas <option value=1000000>Kilometros <option value=1000>metros <option value=10>centimetros <option value=1>milimetros </select> </p> <p> </p></TD><TD width="30">=></TD><TD width="200" valign="top"> <p><b>Conversion de Medidas</b> (Respuesta)<BR> <input Width=20 name=V2 READONLY onChange="calculate(this,document.lengthconv)"> <select Width=60 onChange="calculate(this,document.lengthconv)" name=U2> <option value=304.8>piés <option value=25.4>Pulgadas <option value=1000000>Kilometros <option value=1000>Metros <option value=10>Centimetros <option value=1>Milimetros </select> </p> </p> <p><br /> </p></TD> </form> </TR> <TR> <TD colspan="3"><hr /><br /></TD> </TR> <TR><form name=weightconv> <TD valign="top"><B>Conversión de Peso<br /> </B> (Ingrese el peso)<BR> <input Width=20 name=V1 onChange="calculate(this,document.weightconv)"> <select Width=60 onChange="calculate(this,document.weightconv)" name=U1> <option value=1016064>ton <option value=50803.2>cwt <option value=907200>US ton <option value=12700.8>quarters <option value=6350.293189>stone <option value=453.59237063889>lb. <option value=28.349523165>oz. <option value=1.77184375>drams <option value=0.0648>grains <option value=1000000>tonne <option value=1000>kg <option value=1>g <option value=0.001>mg </select> </TD><TD> => </TD><TD valign="top"> <b>Conversión de Peso<br /> </b> (Ingrese el peso)<BR> <input Width=20 name=V2 READONLY onChange="calculate(this,document.weightconv)"> <select Width=60 onChange="calculate(this,document.weightconv)" name=U2> <option value=1016064>ton <option value=50803.2>cwt <option value=907200>US ton <option value=12700.8>quarters <option value=6350.293189>stone <option value=453.59237063889>lb. <option value=28.349523165>oz. <option value=1.77184375>drams <option value=0.0648>grains <option value=1000000>tonne <option value=1000>kg <option value=1>g <option value=0.001>mg </select> </p></TD> </form> </TR> <tr><td colspan=4><input type=hidden size=2 id="precision" value=6 onChange="this.value=Math.abs(parseInt(this.value));"></td></tr> </TABLE>