想做个简易的彩票系统,选取页面如上图,本人没有学过Js,不知道如何用javascript实现点击botton就能自动将botton上的value值放到text文本框内,功能判断:不能重复选取,一个号码只能选取一次,按照顺序填充进去,填完为止。填满后,如果继续点击botton就提示“你已经选满!".还有个问题不知道有希望知道的解答下:如果后台管理界面设定玩法的时候,当值传到前台选取页面的时候,javasript如何才能接受参数的改动的?谢谢了
调试欢乐多
<script type="text/javascript">
<!--
String.prototype.trim = function(){
return this.replace(/^\s+(.*?)\s+$/,"$1");
}
var count = 0;
function showValue(obj){
count++;
if(count <= document.getElementsByName("otxt").length){
document.getElementById("txt" + count).value = obj.value.trim();
obj.disabled = "disabled";
}else{
alert(" 你已经选满! ");
}
}
//-->
</script>
<input type="text" style="width:25px" id="txt1" name="otxt"/>
<input type="text" style="width:25px" id="txt2" name="otxt"/>
<input type="text" style="width:25px" id="txt3" name="otxt"/>
<input type="text" style="width:25px" id="txt4" name="otxt"/>
<input type="text" style="width:25px" id="txt5" name="otxt"/>
<input type="text" style="width:25px" id="txt6" name="otxt"/>
<br/><br/><br/><input type="button" value=" 05 " onclick="showValue(this)" />
<input type="button" value=" 06 " onclick="showValue(this)" />
<input type="button" value=" 07 " onclick="showValue(this)" />
<input type="button" value=" 08 " onclick="showValue(this)" />
<input type="button" value=" 09 " onclick="showValue(this)" />
<input type="button" value=" 10 " onclick="showValue(this)" />
<input type="button" value=" 11 " onclick="showValue(this)" />
<br/>
<input type="button" value=" 22 " onclick="showValue(this)" />
<input type="button" value=" 23 " onclick="showValue(this)" />
<input type="button" value=" 24 " onclick="showValue(this)" />
<input type="button" value=" 25 " onclick="showValue(this)" />
<input type="button" value=" 26 " onclick="showValue(this)" />
<input type="button" value=" 27 " onclick="showValue(this)" />
<input type="button" value=" 28 " onclick="showValue(this)" />
test(obj){
alert(obj);
var t1 = document.getElementById("t1").value;
var t2 = document.getElementById("t2").value;
var t3 = document.getElementById("t3").value;
var t4 = document.getElementById("t4").value;
var t5 = document.getElementById("t5").value;
var t6 = document.getElementById("t6").value;
}
</script>
<input type="text" name="t1" id="t1" size="1"/>
<input type="text" name="t2" id="t2" size="1"/>
<input type="text" name="t3" id="t3" size="1"/>
<input type="text" name="t4" id="t4" size="1"/>
<input type="text" name="t5" id="t5" size="1"/>
<input type="text" name="t6" id="t6" size="1"/> <br><br><input type="submit" value=" 提交 "/> <input type="reset" value=" 重置 "/>
<br><br><br><input type="button" value=" 05 " id="05" onclick="test(this.id)"/>
<input type="button" value=" 06 " id="06" onclick="test(this.id)"/>
<input type="button" value=" 07 " id="07" onclick="test(this.id)"/>
<input type="button" value=" 08 " id="08" onclick="test(this.id)"/>
<input type="button" value=" 09 " id="09" onclick="test(this.id)"/>
<input type="button" value=" 10 " id="10" onclick="test(this.id)"/>
<input type="button" value=" 11 " id="11" onclick="test(this.id)"/>
<br><br>
<input type="button" value=" 22 " id="22" onclick="test(this.id)"/>
<input type="button" value=" 23 " id="23" onclick="test(this.id)"/>
<input type="button" value=" 24 " id="24" onclick="test(this.id)"/>
<input type="button" value=" 25 " id="25" onclick="test(this.id)"/>
<input type="button" value=" 26 " id="26" onclick="test(this.id)"/>
<input type="button" value=" 27 " id="27" onclick="test(this.id)"/>
<input type="button" value=" 28 " id="28" onclick="test(this.id)"/>
<br><br>
居然打错字:servlet