Reply
ie decrements value on dynamic select menu
Old 01-06-2009, 03:59 PM ie decrements value on dynamic select menu
hiptobesquare's Avatar
Extreme Talker

Posts: 182
Location: London UK
Trades: 0
hello

ive encountered a strange problem only in IE which ive been unable to find a fix for. It goes like this -

Im using JS to dynamically generate a select menu with integers. everytime the selected option is changed, a js function is called which empties the menu and repopulates it, again with integers. I use a variable to remember what the last selected option was so that it doesnt get lost. The trouble is that when the menu repopulates, the selected option is always 1 lower than it should be.

Strangely, if i alert the variable containing currently selected option prior to the select populating itself, the alert gives me the correct value, and on clicking the ok button, the select menu populates as it is supposed to.

if i look, i change the outcome of the experiment. Its a bit like schrodinger's cat, has anybody ever experienced this before?
hiptobesquare is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 01-06-2009, 07:49 PM Re: ie decrements value on dynamic select menu
hiptobesquare's Avatar
Extreme Talker

Posts: 182
Location: London UK
Trades: 0
for anyone who experiences this problem, this is a hack but its the only way i can make ie display the correct value

Code:
for(var d=1; d<6; d++){
  if(active==d){b=true;}else{b=false} 
  select.options[(d-1)] = new Option(d,d,true,b);	}
}
the above code should populate the select with the correct info and highlight the option equalling var active, but in ie it doesnt, so add this below the loop -
Code:
	select.selectedIndex=(active-1);
hiptobesquare is offline
Reply With Quote
View Public Profile
 
Old 01-06-2009, 08:16 PM Re: ie decrements value on dynamic select menu
chrishirst's Avatar
Super Moderator

Posts: 22,277
Location: Blackpool. UK
Trades: 0
do we get to see the original code? just to see if we can spot the problem.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-08-2009, 11:20 AM Re: ie decrements value on dynamic select menu
hiptobesquare's Avatar
Extreme Talker

Posts: 182
Location: London UK
Trades: 0
hi chris, thanks so much for your continued help EVERY time im stuck.

ive spent all day so far trying to isolate this problem, but theres so much interrelated activity going on that i keep getting muddled up, breaking it and starting again. I am still trying though and will post something up asap.

Firstly, to show you the problem you can see the page at www.webdesignamite.co.uk/slidingwizard.php

MAKE SURE YOU ARE USING IE AS IT WORKS OK OTHERWISE

once youve loaded the page, fill in an aperture width, aperture height and select a number of doors, click submit and you will be confronted with a picture of some wardrobe doors. Look to the lower left of screen and you will see a select menu called 1st panel finish, this is the where the problem occurs.

If you select a finish from this menu, a function is called which validates and saves the info into an object, then using this object as a reference, reloads all of the select options and autoselects the one you just chose, and finally fills one of the doors on screen with the finish you selected.

THE PROBLEM....

When the select menu repopulates, it always autoselects the option BEFORE the option that you selected. However, if i alert the variable holding the selected colour before the select menu is populated, it loads the correct value, this makes absolutely no sense to me. If you are interested to see this problem first hand, i have made up a zip file which can run on localhost at - www.webdesignamite.co.uk/sel.zip. Once unzipped in you root directory navigate to http://localhost/sel/slidingwizard.php. The alert box i speak of can be found by searching in slidingwizard.php for alert(info[active]['panel'+d]); Simply commenting and uncommenting this changes the outcome of the experiment.

Any thoughts would be fab.

mark
hiptobesquare is offline
Reply With Quote
View Public Profile
 
Old 01-08-2009, 11:37 AM Re: ie decrements value on dynamic select menu
hiptobesquare's Avatar
Extreme Talker

Posts: 182
Location: London UK
Trades: 0
also here is the same script, but this one cotains the alerted variable

http://www.webdesignamite.co.uk/slid...ardalerted.php

it is exactly the same as

http://www.webdesignamite.co.uk/slidingwizard.php

other than the alert
hiptobesquare is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to ie decrements value on dynamic select menu
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.11963 seconds with 13 queries