/    Sign up×
Community /Pin to ProfileBookmark

DIV display problems

I have the following script that is giving me fits.
Works just how I want in FF2, but goes bananas in MSIE
No error messages with either browser.

Below is the part that I believe is giving me problems.
I can provide more, but below is the only part that doesn’t seem to work.

[code=php]
function ShowDB() {
var obj = document.getElementById(‘LDBase’);
if (obj.value == ”) { alert(‘Load Entries first’); return; }
SplitDB();

var tbl = ”;
tbl = ”; // ‘<div>’;
var str = ”;
var classchange = ”;

for (p=0; p<srec.length; p++) {
tmp = srec[p].split(‘|’);
i = Number(tmp[1]); // alert(srec[p]+’|’+i+’ : ‘+recs[i]);
rec = recs[i].split(‘|’);

if (OptionsToCheck(recs[i]) == true) {
str += ‘<div style=”background-color:yellow;height:10px;”><hr></div>’;
str += ‘<div class=”c0″>’;
str += ‘ <div class=”c1″><em>Opportunity:</em></div> <div class=”c2″>’+rec[1]+'</div><br class=”clear”>’;
str += ‘ <div class=”c1″><em>Activity:</em></div> <div class=”c2″>’+rec[2]+'</div><br class=”clear”>’;
str += ‘ <div class=”c1″><em>Area:</em></div> <div class=”c2″>’+rec[3]+'</div><br class=”clear”>’;
str += ‘ <div class=”c1″><em>City:</em></div> <div class=”c2″>’+rec[4]+'</div><br class=”clear”>’;
str += ‘ <div class=”c1″><em>Contact:</em></div> <div class=”c2″>’+rec[5]+'</div><br class=”clear”>’;
str += ‘ <div class=”c1″><em>E-mail</em></div> <div class=”c2″>’+rec[6]+'</div><br class=”clear”>’;
str += ‘ <div class=”c1″><em>Phone:</em></div> <div class=”c2″>’+rec[9]+'</div><br class=”clear”>’;
str += ‘ <div class=”c1″><em>Fax:</em></div> <div class=”c2″>’+rec[10]+'</div><br class=”clear”>’;
str += ‘ <div class=”c1″><em>Posted:</em></div> <div class=”c2″>’+rec[0]+'</div><br class=”clear”>’;
str += ‘</div>’;
str += ‘<div class=”c3″><em>Description:</em><br>’+rec[7]+'</div>’;
str += ‘<br class=”clear”>’;
// str += ‘</div>’;
}
}
if (str == ”) { str = ‘<h1>No records to display</h1>’; }
str = tbl+str; // +'</div>’;

obj = document.getElementById(‘SDBase’);
obj.innerHTML = str;
}
[/code]

The ‘LDBase’ is a <textarea> that is loaded using ajax and contains the fields to display separated by the ‘|’ symbol and each records ends in ‘}’. I have verified that the data is available and can be parsed correctly.

‘SDBase’ is just another ‘<DIV>’ tag to hold the display of the record fields.

I changed the original design using <TABLE> elements because I had read that MSIE doesn’t work right when placed on the screen using ‘.innerHTML’.
In a table version, I also tried to add appropriate <TBODY> tags, but still nogo.

Instead I am using <DIV> tags with the CSS float attribute. Is there a limitation doing this as well?

Has anyone ever heard of a problem doing this.

Each record display starts with a <HR> followed by a left and right display. On the left are the fields of Opportunity, Activity, Area, … Posted and on the right is the description field of the record entry.
I included a check for when no matching records are found.

Even if you don’t know what the problem is causing the good display in FF and the non-display in MSIE, any hints on where to place any debugging code to determine what needs to be changed? I’m at a loss to know what to change next.

You can see the actual program in operation at: [url]http://www.nova.edu/optometry/placement/jobs.htm[/url]
Using FF, all displays fine. Jumpy screen and no display in MSIE.

Thanks for any thoughts on the matter.

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@konithomimoAug 19.2008 — Without atleast seeing an example of the array data, the best I can say is that instead of using a string and writing to the document using innerHTML(), use DOM functions, such as createElement() and appendChild(). That way you are certain that you can reference the appropriate objects.
Copy linkTweet thisAlerts:
@JMRKERauthorAug 20.2008 — The data is just a text file created by a program called 'FormMail.cgi' provided by the university.

A sample of the data is as follows, but I don't think it has any bearing on the problem.

I have removed the names and email addresses here.

04/01/08 17:25|Providing|Full-time|Other area|New York|[email protected]|High End optical store seeks full and part time Optometrists for the NYC Metro area (LI, NJ), upstate NY, CT, and Puerto Rico. Fast paced and friendly work environment. New Grads are welcome. Top salary and incentives. Contact. [email][email protected][/email] or Fax resume to xxx-792-8181|{|xxx-792-8100|xxx-792-8181|}

04/02/08 15:16|Providing|Sell|Other area|Massachusetts, Berkshire County| [email][email protected][/email]|Resort Area location. Well established practice of 23 years is located in a strip mall on a major street and close to freeways. There are 2,420 sq ft with 2 lanes, a doctor's office, laboratory, and edging room, etc. Seller is asking $281,400. The gross income in 2007 was $451k. Seller sees 160 pts/mo; 40 are new.There are 2 PT Recept, Optical and 3 FT Optician, Billing Asst (1 wife). Ref#OD668.|{|xxx-277-6633| |}

04/02/08 15:42|Providing|Full-time|North-Central|Gainesville, Florida|Dr. |OD needed for ophthalmology practice.

General optometry, CLs, Ocular Disease.

Offices in Gainesville and Chiefland.

Send Resume:

Fax: xxx-331-7552|{|(xxx) 331-7337| |}


04/04/08 16:47|Providing|Sell|South-East Coast|Miami, FL|[email protected]|For sale optical store in kendall Miami, Full equipment (chair & stand, projector, phoropter, slip lamp, tonometer, keratometer, indirect, retinoscopy, lensometer, pupilometer furniture etc) for information call xxx3168245|{|xxx3168245| |}
[/QUOTE]

I'll look into the DOM methods further. Any specific hints about use them that I should be aware of?

Thanks for the look! ?
Copy linkTweet thisAlerts:
@HoboScriptAug 20.2008 — Do some basic debugging... alert out the objects you are referencing:

var obj = document.getElementById('LDBase');

and...

obj = document.getElementById('SDBase');

You say it works in FF2, which leads me to believe your data is correct, but what explodes in IE? You weren't very specific. Does nothing appear.. or what?


I'm not sure why you didn't create separate variables for each of these elements, but w/e make sure they aren't null/undefined.
Copy linkTweet thisAlerts:
@slaughtersAug 20.2008 — ...I'll look into the DOM methods further. Any specific hints about use them that I should be aware of?..[/QUOTE]DOM methods can be very lengthy and verbose. But, you can start off something like this:[code=html] // Create container DIV and place it in the body of the document

divContainer = document.createElement("div");

divContainer.setAttribute("id", "divContainer");
document.body.appendChild(divContainer);

// Style container DIV
divContainer.style.backgroundColor = "yellow";

divContainer.style.height = "10px";

// Create inner container DIV and place it inside the container DIV

divInner = document.createElement("div");

divInner.setAttribute("id", "divInnerContainer");
divContainer.appendChild(divInner);

// Style inner container DIV by assigning class name
divInner.style.className = "c0";
.
.
.
etc..[/code]
Every HTML element has be be created with "createElement". You use "appendChild" to place one element inside another.
Copy linkTweet thisAlerts:
@JMRKERauthorAug 20.2008 — Do some basic debugging... alert out the objects you are referencing:

var obj = document.getElementById('LDBase');

and...

obj = document.getElementById('SDBase');

You say it works in FF2, which leads me to believe your data is correct, but what explodes in IE? You weren't very specific. Does nothing appear.. or what?


I'm not sure why you didn't create separate variables for each of these elements, but w/e make sure they aren't null/undefined.[/QUOTE]


I have not yet changed anything in the test program yet, the link is toward the bottom of post #1.

What happens is that FF displays as expected and as designed after a checkbox is selected. ?

I have since checked the script using Safari on the iMac. Again, no problems with display. ?

The MSIE displays the selections, but when the 'Show Entries' button is pressed after a check box selection of say: 'Entire State',

nothing appears below the button as is expected. ?

There is a horizontal line displayed and some data, but the screen jumps around a bit, but nothing is displayed as stable as seen in the other browsers.

I have checked that the ajax portion is loading the hidden <textarea> element correctly

into the 'LDBase'. I see the data from the text file as posted in #3. I have not spotted any special characters in this text file that might be interpreted as tags.

The 'SDBase' is just a <DIV> where I wanted to put the information parsed from the data by the 'Show Entries' button.

For ease of coding my attempt used .innerHTML, but that approach does not seem to work in MSIE at all.

I don't get any 'null/undefined' errors in any of the browsers. :eek:

I have used alert boxes to debug, but now I'm running out of places to put them to solve this.

I'll be investigating using 'slaughters' methods next, but since the original script works so well

and as expected on 2 of the 3 browsers I have tested on, I was trying to understand the differences so that I would not have to re-code for one specific (!@#$%) browser. :mad:
Copy linkTweet thisAlerts:
@JMRKERauthorAug 20.2008 — Good news --- Bad news.

I re-investigated the data load and parse functions I use to separate the records into fields.

For FF and IE, the data appears to be loading the same way. The contents appear to match ... Good news!

The parse funtion appears to be splitting the information differently in FF vs. IE. The results don't match ... Bad news.

There must be something different in the way FF and IE handle the loaded data.

Haven't seen the difference yet, but at least I have a new (blind?) alley to investigate.

If the information is truly being parsed differently, it might explain the scrambled display in IE.

Does IE handle data differently from FF with characters like:

'carriage return' (n)

or 'line feed' (r)

or End-Of-Line (EOL)

or End-Of-File (EOF)

Like MS uses two characters (CRLF) vs Unix files with only (LF) at the end of each line?

Perhaps I need to pre-process the data differently for IE vs FF before I split the records into fields?

I'll post back later if I can see the problem.
Copy linkTweet thisAlerts:
@DokAug 21.2008 — IE (and Opera in some cases in textarea) use rn whereas Firefox/Safari only use n

To my knowledge JS have no concept of EOL/EOF (as it can't access files)
Copy linkTweet thisAlerts:
@JMRKERauthorAug 21.2008 — Thanks 'Dok', I'll put in a check for both conditions to see if it makes a difference.

The EOL/EOF question was just to be sure that the ajax was not doing something to the file lines or end of file.

At least I have something to try now ... appreciate it.
×

Success!

Help @JMRKER spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...