Los requisitos y el código son los siguientes:
"Este es mi código:"
<input type = "text" id = "precio2" valor = "333" /> <input type = "text" id = "truePrice" value = "" />
<script type = "text/javaScript"> document.getElementById ("precio2"). onKeyUp = function () {document.getElementById ("TruePrice"). Value = this.value;} </script>Pregunta: Ahora, cuando abre esta página, el valor de TruePrice está vacío de forma predeterminada. ¿Cómo puede lograr la apertura predeterminada de TruePrice es la misma que Price2? (Price2 es un valor dinámico)
<input type = "text" id = "truePrice" value = "" /> se fija y no se puede modificar
Una simple implementación mía:
<! DocType html> <html> <fead> <meta http-equiv = "content-type" content = "text/html; charset = utf-8"> <title> test </title> </toad> <body> <nume type = "text" id = "precio2" valor = "333" oneyup = "test (this.value);" type type "id =" precio "valor =" 333 "on KeyUp =" test (this.value); "type" input "id =" precio "valor =" 333 "on KeyUp =" test (this.value); "type" input "id =" precio "valor =" 333 "on Keyup =" test (this.value); "input type" Id = "Price" Valor = "333" id = "TruePrice" value = ""/> <script type = "text/javascript"> var precio2 = document.getElementById ("precio2"). valor; document.getElementById ("truePrice"). valor = precio2; function test (defaultval) {document.getElementById ("truePrice"). Value = valueVal;} </script </script </script </script </bodionEfecto:
El contenido ingresado en el primer cuadro de texto se puede sincronizar con el segundo cuadro de texto