The code above works like the follow.Code:<form> <input type="text" name="source" value="0"> <input type="text" name="copy" value="0"> </form> <script type='text/javascript'> var source = document.getElementsByName('source')[0]; source.onkeyup = function () { var copy = this.form.elements.copy; copy.value = this.value; } </script>
If I enter "someNumber" in the box "source",
The "someNumber" will be simultaneously shown in the box "copy".
It works fine.
I like to make it like the follow.
If I enter "someNumber" in the box "meter",
The "someNumber*0.9144" will be simultaneously shown in the box "yard".
The trial code below doesn't work correctly, but it will show what I want.
Code:trial code <form> <input type="text" name="meter" value="1"> <input type="text" name="yard" value="0.9144"> </form> <script type='text/javascript'> var source = document.getElementsByName('meter')[0]; source.onkeyup = function () { var yard = this.form.elements.yard*0.9144; yard.value = this.value; } </script>



Reply With Quote
Bookmarks