• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Inexplicable behaviour

 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yesterday I was attempting to write a script wherein, I had this Table with a single row and about 10 cells in it. This row was to serve as the header of a table and the user had the option of selecting which all cells he/she wanted in the table for the header row. For every cell, there was a checkbox the user could check/uncheck to add/remove the cell from the row. The checkbox's value was the same as the cell's ID.
Initially what I did was:


In IE this worked just fine, but in FF and Opera the behaviour was completely erratic. The cells got merged into other cells and messed up the display.
Then I created a CSS class named : "hideElems" which had a single property:
display: none;
And I changed the code above to:


Now it worked fine on all browsers. Can anyone explain this?
It's getting to be quite a nagging curiosity. And also, maybe there is something about not fiddling with inline style as opposed to switching between CSS classes from JavaScript?
[ April 01, 2008: Message edited by: Anirvan Majumdar ]
 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i don't see any issues with the block of code, however can you also make sure that after that line are you doing some code which may reset the value.

I quite confident that the code is correct, however if you feel then you can easly debug the javascript in mozilla when compared to IE.

Try fireBug (mozilla addons), after knowing the firebug i started to love javascript programming..

let me if you have any updates...if you still unable to find the bug, please post the code here....
 
Anirvan Majumdar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Mohammed,

I don't think there's anything wrong with the script. Firebug doesn't throw any errors either. As for the code, I think you can try it locally by just creating an HTML document and pasting the code below. At present, I'm taking the style.display approach. In IE it'll work fine, but in FF if you deselect a couple of checkboxes and then reselect them then you'll see what I mean.
After that, just uncomment the the commented script and comment out the style.display part of the script. You'll see that it works fine in FF too now. Let me know if you need something else to see what I mean.

Hopefully someone out there can tell me what causes these aberrant behaviour.

NOTE: You'll need to replace all occurrences of "onclic" with "onclick" to make this code work. The ranch doesn't allow posting of code containing certain script keywords :-/


[ April 01, 2008: Message edited by: Anirvan Majumdar ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Firefox is probably expecting

display="table-cell"

you can just do

display=""; which sets it to the default value

Showing and hiding table cells is probably not the best thing to do.

Eric
reply
    Bookmark Topic Watch Topic
  • New Topic