我是html和java-script的新手。对于我的代码我不断得到我的功能没有定义,我无法弄清楚为什么。香港专业教育学院尝试将脚本移动到头标签和通话后。香港专业教育学院尝试更改功能的名称,以确保它还没有被使用。我想我错过了一些小而愚蠢的东西。任何帮助将不胜感激
selectedCountryPhone
答案 0 :(得分:0)
以下代码更正了您的语法错误,现在正在调用函数(您可以根据需要查看" hello"警告)。
var d = [0,0,0,0,0];
function aaa()
{ alert( "hello" );
for (var i = 0; i<5; i++){
var da = Math.floor(Math.random()*6) +1;
var di = document.getElementById("d" + i);
di.src = "pix/dice" + d + ".gif";
}
}
function newGame(){
}
function click1() {
var total = 0;
for (var i = 0; i <5; i++){
if (d[i] == 1 ) total +=1;}
var loco = document.getElementById("s1");
loco.innerHTML = total;
}
&#13;
<html>
<body>
<h1>Yahtzee</h1>
<div style = "text-align:center;">
<img src = "pix/dice0.gif" id = "d0">
<img src = "pix/dice0.gif" id = "d1">
<img src = "pix/dice0.gif" id = "d2">
<img src = "pix/dice0.gif" id = "d3">
<img src = "pix/dice0.gif" id = "d4">
</div>
<table border =2 align =center>
<tr>
<td class = "c1"> 1's </td>
<td class = "c2"><div class = "scr" id = "s1" onclick= "click1()" > </div> </td>
<td class = "c3" rowspan = "6"><button id = "roll;" onclick = "aaa()";>Roll</button> </td>
</tr>
<tr>
<td class = "c1"> 2's </td>
<td class = "c2"><div class = "scr" id = "s2"> </div></td>
</tr>
<tr>
<td class = "c1"> 3's </td>
<td class = "c2"><div class = "scr" id = "s3"> </div></td>
</tr>
<tr>
<td class = "c1"> 4's </td>
<td class = "c2"><div class = "scr" id = "s4"> </div></td>
</tr>
<tr>
<td class = "c1"> 5's </td>
<td class = "c2"><div class = "scr" id = "s5"> </div></td>
</tr>
<tr>
<td class = "c1"> 6's </td>
<td class = "c2"><div class = "scr" id = "s6"> </div></td>
</tr>
<tr>
<td class = "c1"> 3 of a kind </td>
<td class = "c2"><div class = "scr" id = "k3"> </div></td>
<td class = "c3" rowspan = "8"><button id = "ng" onclick="newGame()"; >New Game </button> </td>
</tr>
<tr>
<td class = "c1"> 4 of a kind </td>
<td class = "c2"><div class = "scr" id = "k4"> </div></td>
</tr>
<tr>
<td class = "c1"> Full House </td>
<td class = "c2"><div class = "scr" id = "fh"> </div></td>
</tr>
<tr>
<td class = "c1"> Sm Straight </td>
<td class = "c2"><div class = "scr" id = "ss"> </div></td>
</tr>
<tr>
<td class = "c1"> Lg Straight </td>
<td class = "c2"><div class = "scr" id = "ls"> </div></td>
</tr>
<tr>
<td class = "c1"> Yahtzee </td>
<td class = "c2"><div class = "scr" id = "yah"> </div></td>
</tr>
<tr>
<td class = "c1"> Chance </td>
<td class = "c2"><div class = "scr" id = "cha"> </div></td>
</tr>
<tr>
<td class = "c1"> Total</td>
<td class = "c2"><div class = "scr" id = "tot"> </div></td>
</tr>
</table>
</body>
&#13;
答案 1 :(得分:0)
错误是您忘记在pandas
之后添加df=pd.concat([df1,df2],keys=['old','new'])
df=df.drop_duplicates(['node1','node2'],keep=False).loc['new']
df=pd.crosstab(df.node1,df.node2).reindex(index=[1,2,3,4,5],columns=[1,2,3,4,5]).fillna(0)
pd.DataFrame(df.values.T+df.values,index=[1,2,3,4,5],columns=[1,2,3,4,5],dtype=int)
Out[894]:
1 2 3 4 5
1 0 0 0 1 0
2 0 0 0 0 0
3 0 0 0 0 1
4 1 0 0 0 0
5 0 0 1 0 0
=
di
var di document.getElementById("d" + i);