Jump to content

Some of my javascript does not work propperly in IE and Chrome but works in FF


McBryver

Recommended Posts

Whats not working is the sendships function and the getRaceInfo function

<form name="reg" id="reg">
<input type="hidden" id="racereal" name="racereal" value="" />
</form>
<div id="register" class="popup_block" align="center" style="opacity:0.8;">

    <h2>Register for Blah Blach Bue!</h2>
        <p><div id="race_info" style=" align:left;"></div></p>
        <p><div id="reg_error" style="color: red;"></div></p>
    <p>Username:</p>
    <p> <input type="text" name="user" id="user"/></p>
        
        <p>Race:</p>

<p><select>
<option>Select a Race!</option>
<option value="1" name="race1" id="race1" onclick="return getRaceInfo(1);">Praline Empire</option>
<option value="2" name="race2" id="race2" onclick="return getRaceInfo(2);">Human Federation</option>
<option value="3" name="race3" id="race3" onclick="return getRaceInfo(3);">Nukari Coalition</option>
<option value="4" name="race4" id="race4" onclick="return getRaceInfo(4);">Creatarian Empire</option>
</select>

    <p>Password</p>
    
    <p><input type="password" name="pass" id="pass"/><br /></p>
    
    <p>Planet Name</p>
    
    <p><input  type="text" name="pname" id="pname" value="Homeworld"/><br /></p>
    
    <p>Email</p>
    
    <p><input  type="text" name="email" id="email"/><br /></p>
    
     <p>Confirm Email</p>
    
    <p><input  type="text" name="email2" id="email2"/><br /></p>
     <p>Security Code</p>
     <p><input type="text" value="" name="security_code" id="security_code"></p>
    
    <p><img src="imagescript.php"/><br /></p>
    <p><div class="button"><a onclick='javascript:register()' style='cursor: pointer;'>Register!</a></div></p>
    </div>
</div>
<script type="text/javascript">
function getRaceInfo(race){
    
    
    if(race == 1){
        document.reg.racereal.value = race;
        document.getElementById("race_info").innerHTML = "<img src='images/praline.gif' /><br /><h4>Free Praline Empire Account!</h4> <p>25% Attack Bonus</p><p>25% Espionage Bonus</p><br />";
    }
    if(race == 2){
         document.reg.racereal.value = race;
        document.getElementById("race_info").innerHTML = "<img src='images/human.gif' /><br /><h4>Free Human Federation Account!</h4><p>25% Income Bonus</p><p>25% Defence Bonus</p><br />";
    }
    if(race == 3){
         document.reg.racereal.value = race;
        document.getElementById("race_info").innerHTML = "<img src='images/nukari.gif' /><br /><h4>Free Nukari Coalition Account!</h4><p>25% Espionage Bonus</p><p>25% Income Bonus</p><br />";
    }
    if(race == 4){
         document.reg.racereal.value = race;
        document.getElementById("race_info").innerHTML = "<img src='images/cretarian.gif' /><br /><h4> FreeCretarian Empire Account!</h4><p>25% Attack Bonus</p><p>25% Defence Bonus</p><br />";
    }
}
</script>

and

<script type="text/javascript">
             function stopShipSend(){
                document.getElementById("sendships").innerHTML = "";
             }
             function sendships(){
                
                var div = '<form method="POST" action="sendships.php"><p align="center">Cargo Ship(100) <input type="text" name="cargoship_send" value="0" /></p> <p align="center">Large Cargo Ship(100) <input type="text" name="cargoship_send" value="0" /></p> <p align="center">Short Range Fighters(100) <input type="text" name="cargoship_send" value="0" /></p> <p align="center">Long Range Fighters(100) <input type="text" name="cargoship_send" value="0" /></p><p align="center">Colony Ships(100) <input type="text" name="cargoship_send" value="0" /></p><p align="center">Battle Crusiers(100) <input type="text" name="cargoship_send" value="0" /></p><p align="center"><input type="checkbox" value="false" name="attack"> Attack Mission</p><p align="center"><input type="checkbox" name="defend" value="true" checked /> Defend This Planet</p><p align="center"><input type="submit" value="Run Mission" name="runm" style="cursor:pointer;" /> | <a href="javascript:stopShipSend();">Cancel Mission</a></p></form>'
                
                document.getElementById("sendships").innerHTML=div;
                
             }
             </script>
             <div id="sendships">
             
             </div>
            <p align="center">   
                <?php if($colony['id']!=$row['id']){?>
                <select name="mission" id="mission">
                <option>Mission</option>
                <option style="cursor: pointer;" onclick="return sendships();">Send Ships</option>
                <option>Send Troops</option>
                <option>Send Espionage Probes</option>
                <option>Make War</option>
                <option>Make Peace!</option>
                </select>
                <?php
                /*
       <input type="submit" style="cursor: pointer;" onclick="return sendships();" value="Mission:Send Ships!" />|
       <input type="submit" style="cursor: pointer;" value="Mission:Send Troops!" />|
       <input type="submit" style="cursor: pointer;" value="Mission:Send Espionage Probes!" />|
       <input type="submit" style="cursor: pointer;" value="Mission:Make War!" />|
       <input type="submit" style="cursor: pointer;" value="Mission:Make Peace!" />
       */ ?>
              <?php  } ?>
       
       
       </p>

 

Any help would be nice thanks,

Brian.

Link to comment
Share on other sites

Ok I got IE's Error Display up and the only error it finds is one associated with the jquery involved in opening a popup that displays the reg form information this is the code that it says is erroring:

<script type="text/javascript">

$(document).ready(function() {
//When you click on a link with class of poplight and the href starts with a # 
$('a.poplight[href^=#]').click(function() {
    var popID = $(this).attr('rel'); //Get Popup Name
    var popURL = $(this).attr('href'); //Get Popup href to define size

    //Pull Query & Variables from href URL
    var query= popURL.split('?');
    var dim= query[1].split('&');
    var popWidth = dim[0].split('=')[1]; //Gets the first query string value

    //Fade in the Popup and add close button
    $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="images/close.png" class="btn_close" title="Close Window" alt="Close" /></a>');

    //Define margin for center alignment (vertical   horizontal) - we add 80px to the height/width to accomodate for the padding  and border width defined in the css
    var popMargTop = ($('#' + popID).height() + 80) / 2;
    var popMargLeft = ($('#' + popID).width() + 80) / 2;

    //Apply Margin to Popup
    $('#' + popID).css({
        'margin-top' : -popMargTop,
        'margin-left' : -popMargLeft
    });  // Error line located here, but it says char 69 and there aren't that many characters on this line.

    //Fade in Background
    $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
    $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies 

    return false;
});

//Close Popups and Fade Layer
$('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
    $('#fade , .popup_block').fadeOut(function() {
        $('#fade, a.close').remove();  //fade them both out
    });
    return false;
});

});

</script>

 

I added a comment where the error is located.

Please help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.