日期:2014-05-16 浏览次数:20368 次
<form method="post" action=""> <input type="text" name="a"> <input type="text" name="b"> <input type="text" name="c"> <input type="text" name="d"> <input type="submit"> </form> <script> var Bdom = document.createElement('span'); var input = document.getElementsByTagName('input'); var _input = []; for (var k in input ) { if(input[k].name)_input[input[k].name] = input[k]; if(input[k].name == 'c') input[k].parentNode.insertBefore(Bdom, input[k]); } _input['a'].onkeyup = function () { Bdom.innerHTML = (this.value == 'PHP') ? '*php' : ''; } _input['b'].onkeyup = function () { if(this.value == '3') _input['c'].value = 3*0.5; } </script>