2017-07-26 7 views
0

私は何をしているのか分かりません...私は2つのパラメータを持つ関数を使用して画像を変更し、 'kendal' 3番目の行と4番目の行の '書き込み'のテキストを別の画像をクリックすると何かに変更....誰かが何か間違って見ますか?2つのパラメータを使用して画像とテキストを変更する必要があります

</style> 

<script> 
function changes(newMessage, imageName) 
{ 
var elementToUpdate = document.getElementById("writing") 
elementToUpdate.innerHTML = newMessage 

var toChange = document.getElementById("kendal") 
toChange.src = imageName 
} 
</script> 

</head> 
<body> 

<form name="tform" id="tform"> 

<table id="table" name="table" border="1"> 
<tbody id="tablebody" name="tablebody"> 

<tr id="firstrow" name="firstrow"> 
    <th id="header1" name="header1" colspan="5">Click on Image to 
Enlarge</th> 
</tr> 

<tr id="secondrow" name="secondrow"> 

    <td id="svu" name="svu"> 
    <input type="image" 
    src="svu-tNail.jpg" 
    alt="Law Order SVU" 
    name="svupic" id="svupic" 
    onclick="changes('svu.jpg, Saint Leo Graduation 2016')"> 
    </td> 

    <td id="ocean" name="ocean"> 
    <input type="image" 
    src="ocean-tNail.jpg" 
    alt="Ocean" 
    name="oceanpic" id="oceanpic" 
    onclick="displayMessage('Bachelors degrees in Sport Business and 
Business Management')" 
    onclick="changeImage('oecan.jpg')"> 
    </td> 

    <td id="pizza" name="pizza"> 
    <input type="image" 
    src="pizza-tNail.jpg" 
    alt="Pizza" 
    name="pizzapic" id="pizzapic" 
    onclick="displayMessage('Minor in Hospitality')" 
    onclick="changeImage('pizza.jpg')"> 
    </td> 

    <td id="sunflower" name="sunflower"> 
    <input type="image" 
    src="sunflower-tNail.jpg" 
    alt="Sunflower" 
    name="sunflowerpic" id="sunflowerpic" 
    onclick="displayMessage('Taken after receiving my diploma!')" 
    onclick="changeImage('sunflower.jpg')"> 
    </td> 

    <td id="softball" name="softball"> 
    <input type="image" 
    src="softball-tNail.jpg" 
    alt="Softball" 
    name="softballpic" id="softballpic" 
    onclick="displayMessage('Graduation was on April 30, 2016 in Saint Leo, 
Florida')" 
    onclick="changeImage('softball.jpg')"> 
    </td> 
</tr> 

<tr id="thirdrow" name="thirdrow"> 

    <th id="kendal" name="kendal" colspan="5"> 
    <input type="image" 
    src="kendal.jpg" 
    alt="Kendal LeFrancois" 
    height="750px" width="750px" 
    name="kendalpic" id="kendalpic"></th> 
</tr> 

<tr id="fourthrow" name="fourthrow"> 

    <th id="writing" name="writing" colspan="5">Kendal LeFrancois</th> 

</tr> 

</tbody> 
</table> 

</form> 

</body> 
</html> 

答えて

0

あなたにはいくつか引用符がありません。これに

<td id="svu" name="svu"> 
    <input type="image" 
    src="svu-tNail.jpg" 
    alt="Law Order SVU" 
    name="svupic" id="svupic" 
    onclick="changes('svu.jpg, Saint Leo Graduation 2016')"> 
    </td> 

:これを変更

<td id="svu" name="svu"> 
    <input type="image" 
    src="svu-tNail.jpg" 
    alt="Law Order SVU" 
    name="svupic" id="svupic" 
    onclick="changes('svu.jpg', 'Saint Leo Graduation 2016')"> 
    </td> 
0

そこに多くのエラーがあると、ここでそれを修正する方法です:

の1-

2 - "フォーム" タグを削除スクリプトに含まれていない関数changeMes​​sageとchangeImageがあります(あなたの関数はchanges(messeage,image)です)

あなたはscript-に

4 - 最初のパラメータはメッセージではない画像である各なステートメントの終わりに​​3210を追加するforgget

3-、また、あなたが引用符を逃した:

変更:onclick="changes('svu.jpg, Saint Leo Graduation 2016')"

へ:onclick="changes('Saint Leo Graduation 2016','svu.jpg')">

</style> 
 

 
<script> 
 
function changes(newMessage, imageName) 
 
{ 
 
var elementToUpdate = document.getElementById("writing"); 
 
elementToUpdate.innerHTML = newMessage; 
 

 
var toChange = document.getElementById("kendal"); 
 
toChange.src = imageName; 
 
} 
 
</script> 
 

 
</head> 
 
<body> 
 

 

 
<table id="table" name="table" border="1"> 
 
<tbody id="tablebody" name="tablebody"> 
 

 
<tr id="firstrow" name="firstrow"> 
 
    <th id="header1" name="header1" colspan="5">Click on Image to 
 
Enlarge</th> 
 
</tr> 
 

 
<tr id="secondrow" name="secondrow"> 
 

 
    <td id="svu" name="svu"> 
 
    <input type="image" 
 
    src="svu-tNail.jpg" 
 
    alt="Law Order SVU" 
 
    name="svupic" id="svupic" 
 
    onclick="changes('Saint Leo Graduation 2016','svu.jpg')"> 
 
    </td> 
 

 
    <td id="ocean" name="ocean"> 
 
    <input type="image" 
 
    src="ocean-tNail.jpg" 
 
    alt="Ocean" 
 
    name="oceanpic" id="oceanpic" 
 
    onclick="changes('Bachelors degrees in Sport Business and Business Management','oecan.jpg')"> 
 
    </td> 
 

 
    <td id="pizza" name="pizza"> 
 
    <input type="image" 
 
    src="pizza-tNail.jpg" 
 
    alt="Pizza" 
 
    name="pizzapic" id="pizzapic" 
 
    onclick="changes('Minor in Hospitality','pizza.jpg')" 
 
    </td> 
 

 
    <td id="sunflower" name="sunflower"> 
 
    <input type="image" 
 
    src="sunflower-tNail.jpg" 
 
    alt="Sunflower" 
 
    name="sunflowerpic" id="sunflowerpic" 
 
    onclick="changes('Taken after receiving my diploma!','sunflower.jpg')"> 
 
    </td> 
 

 
    <td id="softball" name="softball"> 
 
    <input type="image" 
 
    src="softball-tNail.jpg" 
 
    alt="Softball" 
 
    name="softballpic" id="softballpic" 
 
    onclick="changes('Graduation was on April 30, 2016 in Saint Leo, Florida','softball.jpg')"> 
 
    </td> 
 
</tr> 
 

 
<tr id="thirdrow" name="thirdrow"> 
 

 
    <th id="kendal" name="kendal" colspan="5"> 
 
    <input type="image" 
 
    src="kendal.jpg" 
 
    alt="Kendal LeFrancois" 
 
    height="750px" width="750px" 
 
    name="kendalpic" id="kendalpic"></th> 
 
</tr> 
 

 
<tr id="fourthrow" name="fourthrow"> 
 

 
    <th id="writing" name="writing" colspan="5">Kendal LeFrancois</th> 
 

 
</tr> 
 

 
</tbody> 
 
</table> 
 

 

 
</body>