PDA

View Full Version : IE Error Please Help


jstestpager92
03-24-2008, 05:25 AM
So I have created a video poker game using javacript, it works perfectly in firefox, but in internet explorer nothing works 0.o. I cant figure out why. Here is the script(its kinda long):

<HTML>
<HEAD>
<SCRIPT LANGUAGE="Javascript">
function clear_js_msg() {
document.getElementById('error_p').innerHTML = ""
}
dealt=false
game_score = 10
function deal_cards(form) {
if(dealt == false){
dealt=true
card_1 = Math.floor(Math.random() * 1000 % 52)
do {
card_2 = Math.floor(Math.random() * 1000 % 52)
}while(card_1 == card_2)
do {
card_3 = Math.floor(Math.random() * 1000 % 52)
}while(card_1 == card_3 || card_2 == card_3)
do {
card_4 = Math.floor(Math.random() * 1000 % 52)
}while(card_1 == card_4 || card_2 == card_4 || card_3 == card_4)
do {
card_5 = Math.floor(Math.random() * 1000 % 52)
}while(card_1 == card_5 || card_2 == card_5 || card_3 == card_5 || card_4 == card_5)
document.card_0.src = "http://www.college1.com/images/cards/gbCard" + card_1 + ".gif"
document.card_1.src = "http://www.college1.com/images/cards/gbCard" + card_2 + ".gif"
document.card_2.src = "http://www.college1.com/images/cards/gbCard" + card_3 + ".gif"
document.card_3.src = "http://www.college1.com/images/cards/gbCard" + card_4 + ".gif"
document.card_4.src = "http://www.college1.com/images/cards/gbCard" + card_5 + ".gif"
confirm01 = true
confirm02 = false
setTimeout("clear_clicks()",1)
game_score = game_score - 2
document.getElementById('score_p').innerHTML = "<FONT COLOR='blue'><h1><b>Score: " + game_score + "</b></h1></FONT>";
document.getElementById('error_p').innerHTML = ""
}
else if(dealt){
document.getElementById('error_p').innerHTML = "<FONT COLOR='red'><h2>Please Finish Your Current Game Before Dealing A New Hand</H2></FONT>"
}
else document.getElementById('error_p').innerHTML = "<FONT COLOR='red'><h2>Script Error</H2></FONT>"
}
confirm01 = true
true0 = true
confirm02 = false
function sortNumber(a,b)
{
return a - b;
}
function burn_cards() {
card2_1 = card_1
card2_2 = card_2
card2_3 = card_3
card2_4 = card_4
card2_5 = card_5
if(dealt) {
if(document.score_box.check_0.checked && document.score_box.check_1.checked && document.score_box.check_2.checked && document.score_box.check_3.checked && document.score_box.check_4.checked && confirm01 == true) {
document.getElementById('error_p').innerHTML = "<FORM NAME='confirm01_form'><FONT COLOR='red'><h2>Are you sure you would not like to discard ANY of your cards?<br>Yes<INPUT TYPE='RADIO' NAME='confirm01' VALUE='yes'><BR>No<INPUT TYPE='RADIO' NAME='confirm01' VALUE='no'><br><input TYPE='BUTTON' onClick='Javascript:test_value()' VALUE='Submit'></H2></FONT>"
}
else if(document.score_box.check_0.checked == false && document.score_box.check_1.checked == false && document.score_box.check_2.checked == false && document.score_box.check_3.checked == false && document.score_box.check_4.checked == false && confirm01 == true) {
document.getElementById('error_p').innerHTML = "<FORM NAME='confirm01_form'><FONT COLOR='red'><h2>Are you sure you would like to discard ALL your cards?<br>Yes<INPUT TYPE='RADIO' NAME='confirm01' VALUE='yes'><BR>No<INPUT TYPE='RADIO' NAME='confirm01' VALUE='no'><br><input TYPE='BUTTON' onClick='Javascript:test_value()' VALUE='Submit'></H2></FONT>"
}
else confirm02 = true
if(dealt == true && confirm02 == true) {
document.getElementById('error_p').innerHTML = ""
if(document.score_box.check_0.checked == false) {
do {
card_1 = Math.floor(Math.random() * 1000 % 52)
}while(card_5 == card_1 || card_2 == card_1 || card_3 == card_1 || card_4 == card_1 || card2_1 == card_1 || card2_2 == card_1 || card2_3 == card_1 || card2_4 == card_1 || card2_5 == card_1)
document.card_0.src = "http://www.college1.com/images/cards/gbCard" + card_1 + ".gif"
}
if(document.score_box.check_1.checked == false) {
do {
card_2 = Math.floor(Math.random() * 1000 % 52)
}while(card_5 == card_2 || card_1 == card_2 || card_3 == card_2 || card_2 == card_1 || card2_1 == card_2 || card2_2 == card_2 || card2_3 == card_2 || card2_4 == card_2 || card2_5 == card_2)
document.card_1.src = "http://www.college1.com/images/cards/gbCard" + card_2 + ".gif"
}
if(document.score_box.check_2.checked == false) {
do {
card_3 = Math.floor(Math.random() * 1000 % 52)
}while(card_5 == card_3 || card_2 == card_3 || card_1 == card_3 || card_4 == card_3 || card2_1 == card_3 || card2_2 == card_3 || card2_3 == card_3 || card2_4 == card_3 || card2_5 == card_3)
document.card_2.src = "http://www.college1.com/images/cards/gbCard" + card_3 + ".gif"
}
if(document.score_box.check_3.checked == false) {
do {
card_4 = Math.floor(Math.random() * 1000 % 52)
}while(card_5 == card_4 || card_2 == card_4 || card_3 == card_4 || card_1 == card_4 || card2_1 == card_4 || card2_2 == card_4 || card2_4 == card_1 || card2_4 == card_4 || card2_5 == card_4)
document.card_3.src = "http://www.college1.com/images/cards/gbCard" + card_4 + ".gif"
}
if(document.score_box.check_4.checked == false) {
do {
card_5 = Math.floor(Math.random() * 1000 % 52)
}while(card_1 == card_5 || card_2 == card_5 || card_3 == card_5 || card_4 == card_5 || card2_1 == card_5 || card2_2 == card_5 || card2_3 == card_5 || card2_5 == card_1 || card2_5 == card_5)
document.card_4.src = "http://www.college1.com/images/cards/gbCard" + card_5 + ".gif"
}
setTimeout("score_hand()",1)
confirm01 = true
confirm02 = false
}
}
else if(dealt == false) document.getElementById('error_p').innerHTML = "<FONT COLOR='red'><h2>You Have Not Dealt Yet</H2></FONT>"
else if(dealt != false && dealt != true) parent.Mainpage.document.getElementById('error_p').innerHTML = "<FONT COLOR='red'><h2>Script Error Please Contact Administration!</H2></FONT>"
}
function score_hand() {
other_cards = new Array(2)
other_cards[0] = null
other_cards[1] = null
hand_points = 0
pairs = 0
hand_type = 0
card_count = -1
flush = false
dealt = false
straight = false
cardvalue1 = card_1 % 13 + 1
cardvalue2 = card_2 % 13 + 1
cardvalue3 = card_3 % 13 + 1
cardvalue4 = card_4 % 13 + 1
cardvalue5 = card_5 % 13 + 1
if(cardvalue1 == 1) cardvalue1=14
if(cardvalue2 == 1) cardvalue2=14
if(cardvalue3 == 1) cardvalue3=14
if(cardvalue4 == 1) cardvalue4=14
if(cardvalue5 == 1) cardvalue5=14
cardsuit1 = Math.floor(card_1/13 +1)
cardsuit2 = Math.floor(card_2/13 +1)
cardsuit3 = Math.floor(card_3/13 +1)
cardsuit4 = Math.floor(card_4/13 +1)
cardsuit5 = Math.floor(card_5/13 +1)
if(cardsuit1 == 1 && cardsuit2==1 & cardsuit3==1 && cardsuit4==1 && cardsuit5==1) flush=true
if(cardsuit1 == 2 && cardsuit2==2 & cardsuit3==2 && cardsuit4==2 && cardsuit5==2) flush=true
if(cardsuit1 == 3 && cardsuit2==3 & cardsuit3==3 && cardsuit4==3 && cardsuit5==3) flush=true
if(cardsuit1 == 4 && cardsuit2==4 & cardsuit3==4 && cardsuit4==4 && cardsuit5==4) flush=true
// cardsuit returns 1 for clubs, 2 for diamonds, 3 for hearts, and 4 for spades
var hand = new Array();
hand[0] = cardvalue1
hand[1] = cardvalue2
hand[2] = cardvalue3
hand[3] = cardvalue4
hand[4] = cardvalue5
arranged2 = hand.sort(sortNumber);
arranged = arranged2.toString()
var hand_arr2 = new Array();
hand_arr2 = arranged.split(',');
var hand_arr = new Array();
hand_arr[0] = hand_arr2[0] * 1
hand_arr[1] = hand_arr2[1] * 1
hand_arr[2] = hand_arr2[2] * 1
hand_arr[3] = hand_arr2[3] * 1
hand_arr[4] = hand_arr2[4] * 1
if(hand_arr[0] == (hand_arr[1] - 1) && hand_arr[0] == (hand_arr[2] - 2) && hand_arr[0] == (hand_arr[3] - 3) && hand_arr[0] == (hand_arr[4] - 4)) straight = true
if(cardvalue1 == cardvalue2) pairs++
if(cardvalue1 == cardvalue3) pairs++
if(cardvalue1 == cardvalue4) pairs++
if(cardvalue1 == cardvalue5) pairs++
if(cardvalue2 == cardvalue3) pairs++
if(cardvalue2 == cardvalue4) pairs++
if(cardvalue2 == cardvalue5) pairs++
if(cardvalue3 == cardvalue4) pairs++
if(cardvalue3 == cardvalue5) pairs++
if(cardvalue4 == cardvalue5) pairs++
if(pairs == 1) {
hand_type = "One Pair"
hand_points = 2
}
if(pairs == 2) {
hand_type = "Two Pair"
hand_points = 4
}
if(pairs == 3) {
hand_type = "Three of a Kind"
hand_points = 8
}
if(straight == true && flush != true) {
hand_type = "A Straight"
hand_points = 10
}
if(flush == true && straight != true) {
hand_type = "A Flush"
hand_points = 15
}
if(pairs == 4) {
hand_type = "A Full House"
hand_points = 20
}
if(pairs == 5) {
hand_type = "Error 226 Please Contact Admin"
hand_points = 30
}
if(pairs == 6) {
hand_type = "Four of a Kind"
hand_points = 50
}
if(flush == true && straight == true && hand_arr[0] != 10) {
hand_type = "A Straight Flush"
hand_points =100
}
if(flush == true && straight == true && hand_arr[0] == 10 && hand_arr[4] == 14) {
hand_type = "A Royal Flush"
hand_points = 750
}
if(hand_points == 750 || hand_points == 100 || hand_points == 50) {
game_score += hand_points
document.getElementById('score_p').innerHTML = "<FONT COLOR='blue'><h1><b>Score: " + game_score + "</b></h1></FONT>"
document.getElementById('error_p').innerHTML = "<font color== 'red'><h1> Congratulations You Got " + hand_type + "!!!! You Received " + hand_points + " points.<br>Press Deal to Begin A New Hand!</H1></font>";
}
else if(hand_type != 0) {
game_score += hand_points
document.getElementById('score_p').innerHTML = "<FONT COLOR='blue'><h1><b>Score: " + game_score + "</b></h1></FONT>"
document.getElementById('error_p').innerHTML = "<font color=='red'><h1>You Got " + hand_type + "!!!! You Received " + hand_points + " points.<br>Press Deal to Begin A New Hand!</H1></font>";
}
else if(hand_type == 0) {
document.getElementById('score_p').innerHTML = "<FONT COLOR='blue'><h1><b>Score: " + game_score + "</b></h1></FONT>"
document.getElementById('error_p').innerHTML = "<font color=='red'><h1>Sorry you did not score any points.<br>Press Deal to Begin A New Hand!</H1></font>";
}
}
function test_value() {
if(document.confirm01_form.confirm01[0].checked == true) {
document.getElementById('error_p').innerHTML = ""
confirm01 = false
confirm02 = true
setTimeout("burn_cards()",1)
}
else if(document.confirm01_form.confirm01[1].checked == true) {
document.getElementById('error_p').innerHTML = ""
confirm01 = false
confirm02 = false
setTimeout("change_back()",1)
}
}
function change_back() {
confirm01 = true
confirm02 = false
}
function clear_clicks() {
if(document.score_box.check_0.checked) {
document.score_box.check_0.click()
}
if(document.score_box.check_1.checked) {
document.score_box.check_1.click()
}
if(document.score_box.check_2.checked) {
document.score_box.check_2.click()
}
if(document.score_box.check_3.checked) {
document.score_box.check_3.click()
}
if(document.score_box.check_4.checked) {
document.score_box.check_4.click()
}
}
function showCards() {
number_of_cards=0
while (number_of_cards < 5) {
document.write("<td><img SRC='http://www.college1.com/images/cards/gbCard52.gif' NAME='card_" +number_of_cards+"'></td>")
number_of_cards++
}
}
function show_checks(){
number_of_cards2 = 0
while(number_of_cards2 < 5){
document.write("<td><center><INPUT TYPE='CHECKBOX' NAME='check_" + number_of_cards2 + "'><br><b>Hold</b></center></td>")
number_of_cards2++
}
}
function contract_rules() {
document.getElementById('rules2').innerHTML = "<b>To start click the deal cards button. After dealing check whichever cards you would like to hold and click the burn cards button. Your score will be instantly updated and a message will appear. Click deal to start your next game.<br>Dealing costs 1 dollar.<br>Royal Flush: 750<br>Straight Flush: 100<br>Four of A Kind: 50<br>Full House: 20<br>Flush: 15<br>Straight: 10<br>Three of a kind : 8<br>Two Pair: 4<br>One Pair: 2</b>";
setTimeout("contract_rules2()",1)
}
function contract_rules2() {
document.getElementById('rules3').innerHTML = ""
}
function expand_rules() {
document.getElementById('rules2').innerHTML = "<b>Poker is a competitive, card, betting game. You are dealt 5 cards in the beginning with the object of creating the best hand possible. After reviewing your hand choose which cards to discard and then press the burn cards button and those cards will be randomly replaced with new cards. The highest possible hand is a royal flush which is 10, Jack, Queen, King, and Ace all of the same suit. Next is the straight flush which contains consecutive cards such as 2,3,4,5,6 of the same suit. Following that is four of a kind which is a hand containing four cards of the same value and any other card (ex. k,k,k,k,2). Next is a full house which contains three cards of the same value and a pair(two cards of the same value) ex. 2,2,2,3,3. The next highest hand is a flush which contains cards of any value that all have the same suit (ex. 2S,6S,9S,KS,AS). Next is a regular straight which contains cards of any suit in a consecutive order (ex. 9,10,J,Q,K). Then there is two pair which contains two unique pairs(two groups of two cards of the same value) and any other card (ex. 5,5,9,9,A). Finally there is a pair which contains two cards of the same value and any other three cards (ex. K,K,5,2,8). How to use our video poker and how it is scored is explained below.<br>To start click the deal cards button. After dealing check whichever cards you would like to hold and click the burn cards button. Your score will be instantly updated and a message will appear. Click deal to start your next game.<br>Dealing costs 1 dollar.<br>Royal Flush: 750<br>Straight Flush: 100<br>Four of A Kind: 50<br>Full House: 20<br>Flush: 15<br>Straight: 10<br>Three of a kind : 8<br>Two Pair: 4<br>One Pair: 2";
setTimeout("expand_rules2()",1)
}
function expand_rules2() {
document.getElementById('rules4').innerHTML = "<a href='Javascript:contract_rules()'><h2><<< Contract</h2></a></b>"
}
</SCRIPT></HEAD><BODY onload="clear_js_msg()">
<p><center><h1><u>Video Poker</u></h1></center></p>
<center><table BORDER=0 ><tr>
<td align = left><form name="score_box"><input TYPE="BUTTON" onClick="Javascript:deal_cards(this.form)" VALUE="Deal Cards > > >">
<script LANGUAGE="Javascript">showCards()</script></td>
<td><input TYPE="BUTTON" onClick="Javascript:burn_cards()" VALUE="< < < Burn Cards"></td>
<td><p id = "timer">Time: <br> 2 Minutes 0 Seconds</p></td>
</tr>
<tr><td></td><script LANGUAGE="Javascript">show_checks()</script>
</tr></table></center>
<center><table BORDER=0><tr>
<p id="score_p"><FONT COLOR='blue'><H1>Score: 10</H1></FONT></p>
</tr><tr>
<p id="error_p"><FONT COLOR='red'><h1>Your Browser Must Support JavaScript for you to play this game!</h1></font></p>
</tr></table></center>
<hr>
<center><h2><b>Rules </b></h2></center>
<center><table BORDER=0><tr>
<td><p id="rules"></p></td></tr>
<tr><td><p id="rules2"><b>To start click the deal cards button. After dealing check whichever cards you would like to hold and click the burn cards button. Your score will be instantly updated and a message will appear. Click deal to start your next game.<br>Dealing costs 1 dollar.<br>Royal Flush: 750<br>Straight Flush: 100<br>Four of A Kind: 50<br>Full House: 20<br>Flush: 15<br>Straight: 10<br>Three of a kind : 8<br>Two Pair: 4<br>One Pair: 2</b></p></td></tr>
<td><tr><p id="rules3"><h2><a href="Javascript:expand_rules()">Expand >>></a></h2></p></tr></td>
</table></center>
<center><p id="rules 4"></p></center>
<hr>
</BODY></HTML>

Kor
03-24-2008, 11:15 AM
I doubt it works even in FF, as long as you must have used the getElementById() and ids to refer elements. And give your document a DOCTYPE.

jstestpager92
03-25-2008, 05:53 AM
I dont really understand your post, but yes it definitely doeas work in firefox, I have tested it and I gave my document a doctype and validated it at a w3c website but it still wont work :confused:

jstestpager92
03-25-2008, 07:36 AM
so i need to rewrite this without the getelementbyid().innerhtm stuff I found a website http://slayeroffice.com/articles/innerHTML_alternatives/ that shows alternatives, but it is all way over my head so if someone could help that would be amazing.

jstestpager92
03-26-2008, 02:58 AM
nevermind i fixed it :)