Macromedia Dreamweaver 8 编程 会的进
Dreamweaver 刚学 不太会 高手指点下 自已不懂
我想编写一段代码:1.文本域(1)*文本域(2)=文本域(3)
2.文本域(1)和文本域(2)都不能不写数字
3.文本域(1)和文本域(2)都不能大于10
还有看别人打代码太厉害了 我不会 在Dreamweaver里有代码吗 哪里?
别人打前面几个单词后面就有提示了 为什么 我打却没有? 如何设置?
参考答案:是用JAVASCIPT实现
<html>
<head>
<script language=javascript>
function a ()
{
var i1,i2
i1 = window.document.getElementById('id1').value
i2 = window.document.getElementById('id2').value
if(i1 ==""|| i2 =="" || isdigit(i1) ==0 || isdigit(i2) ==0)
alert("请输入数字") ;
else if( i1 > 10 || i2 > 10)
alert("请输入小于10的数") ;
else
window.document.getElementById('id3').value = window.document.getElementById('id1').value *window.document.getElementById('id2').value
}
function isdigit(s)
{
var r,re;
re = /\d*/i; //\d表示数字,*表示匹配多个数字
r = s.match(re);
return (r==s)?1:0;
}
</script>
</head>
<body MS_POSITIONING="GridLayout">
<input type=text id=id1 NAME="id1"> x <input type=text id=id2 NAME="id2"> = <input type=text id=id3 NAME="id3">
<input type=button onclick =a() value=计算 ID="Button1" NAME="Button1">
</body>
</html>