-2
這是我的HTML。我認爲HTML是無錯的。使用按鈕來引用單選按鈕選項
我的JavaScript是用psydocode編寫的,因爲我用正確的語法解決了大量的問題。
如果玩家沒有死亡,3000英里需要是一個每次點擊按鈕時都會明顯改變的值。
我需要弄清楚將播放按鈕鏈接到單選按鈕選項的語法,檢查用戶是否隨機死亡 - 如果沒有 - 從需要旅行的總英里數減去500英里(3000),然後檢查里程計數器是否爲0.
謝謝你的時間!
<body>
<h1>Coal Train the Game!<h1>
<h3> Pick one track. Be careful to read the track descriptions,
some tracks have a better chance to reach Oregon than others!
After strategically choosing a track, click the button to travel 500 miles.
At the end of 3000 miles, you win the game!<h3>
<img src="coaltrain.jpg" alt="Picture of Train" style="width:600px;height:300">
<table>
<tr>
<td valign="top"><input type="radio" name="You Changed Tracks!" id="Track_1" value="1" onclick="alert(this.name);" /></td>
<td valign="top" style="color: red;">Scenic Bridge Track - Choose this track if you enjoy old bridges!</td>
</tr>
<tr>
<td valign="top"><input type="radio" name="You Changed Tracks!" id="Track_2" value="2" checked="checked" onclick="alert(this.name);" /></td>
<td valign="top" style="color: blue;">Outlaw Town Track - Choose this track if you enjoy talking to unrefined characters!</td>
</tr>
<tr>
<td valign="top"><input type="radio" name="You Changed Tracks!" id="Track_3" value="3" onclick="alert(this.name);" /></td>
<td valign="top" style="color: green;">Active Volcano Track - Choose this track if you enjoy liquid hot magma!</td>
</tr>
<tr>
<td valign="top"><input type="radio" name="You Changed Tracks!" id="Track_4" value="4" onclick="alert(this.name);" /></td>
<td valign="top" style="color: orange;">Boring Track - Choose this track if you prefer safety over experience</td>
</tr>
</table>
<div id="Miles" value = "3000"> 3000 Miles to Travel!</div>
<button id="Play" onclick="myFunction()">Play</button>
</html>
function myFunction = If Track_1 = "checked"
then
Math.Random()<=.25 then alert(The Coal Train died by falling through a bridge!)
else
var Miles
var OneTurn
var Total = "Miles"-"One Turn"
if var Miles = 0
then alert(Your Coal Train made it too Oregon! Congrats!);
你的HTML有不匹配的''和'
'標籤。能否請您另外修復它,並縮進更好? – Telokis 2015-03-03 04:11:42,沒有真正的問題在這裏。是你希望我們爲你寫代碼嗎?我不明白。 – Telokis 2015-03-03 04:12:34
分享你有什麼特權d(myFunction) - 嘗試通過編輯http://jsfiddle.net/arunpjohny/r4qbkm2L/5/來創建演示 – 2015-03-03 04:15:14