HighDots Forums  

Changing Image works in FX, not IE?

Javascript JavaScript language (comp.lang.javascript)


Discuss Changing Image works in FX, not IE? in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jessica
 
Posts: n/a

Default Changing Image works in FX, not IE? - 06-04-2006 , 05:40 PM






Page: http://www.doublooncove.com/signup.php

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.

CODE
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*
}
}



CODE

<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?


Reply With Quote
  #2  
Old   
Janwillem Borleffs
 
Posts: n/a

Default Re: Changing Image works in FX, not IE? - 06-04-2006 , 06:24 PM






Jessica wrote:
Quote:
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.

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)

In general, run your page through an XHTML validator, because as it is now,
it's currently not valid.


JW




Reply With Quote
  #3  
Old   
Stephen Chalmers
 
Posts: n/a

Default Re: Changing Image works in FX, not IE? - 06-04-2006 , 06:27 PM




Jessica wrote:
Quote:
Page: http://www.doublooncove.com/signup.php

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.
Check your HTML. The options in the gender select box have no values
assigned. If you alert the .src you get: .......pirates//.gif

Also, lose the HTML comments inside the script tags, as they are not
required and in your case incorrect, causing Opera to complain.

There may be more errors than these.



Reply With Quote
  #4  
Old   
Jessica Parker
 
Posts: n/a

Default Re: Changing Image works in FX, not IE? - 06-04-2006 , 08:39 PM



Thank you both so much, it works perfectly now!

The html comments were there because my fiance told me it would prevent
browsers that didn't support the code from trying to read it. So this
is not needed?

Again, thanks a ton, now I can finally let my IE users pick their
character


Reply With Quote
  #5  
Old   
Randy Webb
 
Posts: n/a

Default Re: Changing Image works in FX, not IE? - 06-04-2006 , 10:32 PM



Jessica Parker said the following on 6/4/2006 8:39 PM:
Quote:
Thank you both so much, it works perfectly now!
Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

<URL: http://www.safalra.com/special/googlegroupsreply/ >

Quote:
The html comments were there because my fiance told me it would prevent
browsers that didn't support the code from trying to read it. So this
is not needed?
No, it is not needed and in XHTML it can be disastrous.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.