Jump to content


Photo

Changing Image works in FX, not IE?


  • Please log in to reply
1 reply to this topic

#1 Jessica

Jessica
  • Staff Alumni
  • This is not my name.
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 03 June 2006 - 05:12 PM

Page: [a href=\"http://www.doublooncove.com/signup.php\" target=\"_blank\"]Game Sign Up Form[/a]

Problem: In Firefox, the changes work fine. In IE, the images just disappear, and there is a broken image. The images are THERE. Some are blank images (like placeholders, since the male character is shirtless, his shirt is blank). But they do exist.

Here is a sample of the code, there are several of these functions but they're all the same just different parts.

function change_gender(){
    if(!document.images){
        return
    }else{
    document.images.bodygender.src="http://www.doublooncove.com/images/pirates/" + document.signup.gender.options[document.signup.gender.selectedIndex].value + "/" + document.signup.gender.options[document.signup.gender.selectedIndex].value + ".gif"
    
    document.images.hairback.src="http://www.doublooncove.com/images/pirates/" + document.signup.gender.options[document.signup.gender.selectedIndex].value + "/hair/" + document.signup.hair.options[document.signup.hair.selectedIndex].value + "/hair_" + document.signup.hair.options[document.signup.hair.selectedIndex].value + "_" + document.signup.hair_color.options[document.signup.hair_color.selectedIndex].value + "_back.gif"
            
    document.images.hairfront.src="http://www.doublooncove.com/images/pirates/" + document.signup.gender.options[document.signup.gender.selectedIndex].value + "/hair/" + document.signup.hair.options[document.signup.hair.selectedIndex].value + "/hair_" + document.signup.hair.options[document.signup.hair.selectedIndex].value + "_" + document.signup.hair_color.options[document.signup.hair_color.selectedIndex].value + "_front.gif"
    *snip*
    }
}


<td><b>Gender:</b></td>
<td>
    <select size="1" name="gender" onChange="change_gender()">
    <?
    if($info['gender'] == 'female'){
        print '<option select>female</option>';
        print '<option>male</option>';
    }else{
        print '<option select>male</option>';
        print '<option>female</option>';
    }
    ?>
    </select>
</td>

Any ideas?
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#2 Jessica

Jessica
  • Staff Alumni
  • This is not my name.
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 05 June 2006 - 12:42 AM

SOLVED thanks to Google Groups & comp.lang.javascript.

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]1. For the gender select, you don't define a value. So, instead of
referencing:

document.signup.gender.options[...].value

You should reference:

document.signup.gender.options[...].text

2. @ line 219 of rendered code: <option select>male</option>

This should be either:

<option selected>male</option>

Or (even better and complient with the specified doctype):

<option selected="selected">male</option>

3. @ line 206 of rendered code: <img src="'.$url.'hat_'.$hat.'.gif"
(unparsed PHP code) [/quote]
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users