Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

control span bgcolor from data binding .csv file ?

Status
Not open for further replies.

mac4511

Technical User
Apr 26, 2001
14
GB
Hi,
i'm struggling to get control of the bgcolor or image of SPANs in Tables. I think my problem is not understanding the name hierarchy of Table/Spans/values etc.

I want to control the bgcolor or bgimage of the individual span with the color value given in the csv / text file. I only need it to work in IE 4.0+ and the colours or bgimages to be defined as the table is written. The entries could be from 1 line to 100 with various colour definitions called for although typically white or red. I cannot change the SPAN bgcolor from outside the table.

Can anybody help me please?
Thanks in advance.

mac


Code:
<HTML>
<HEAD>

<TITLE>Data Binding Example</TITLE>
</HEAD>
<BODY>
<div > 
  <p align=&quot;left&quot;><OBJECT ID=&quot;alphabet&quot; CLASSID=&quot;clsid:333C7BC4-460F-11D0-BC04-0080C7055A83&quot;>
      <PARAM NAME=&quot;DataURL&quot; VALUE=&quot;alphabet.txt&quot;>
      <PARAM NAME=&quot;UseHeader&quot; VALUE=&quot;True&quot;>
      <embed dataurl=&quot;alphabet.txt&quot; useheader=&quot;True&quot; src=&quot;alphabet.txt&quot;>
      </embed> 
    </OBJECT> </p>
  <div >
<table datasrc=&quot;#alphabet&quot; border=&quot;1&quot; name=&quot;mytable&quot;>
      <thead> 
      <tr bgcolor=&quot;YELLOW&quot;> 
        <th >Letter</th>
        <th >Colour</th>
      </tr>
      </thead><tbody name=&quot;frank&quot;> 
      <tr align=&quot;CENTER&quot;> 
        <td> 
          <div datafld=&quot;Letter&quot;></div>
        </td>
        <td><span datafld=&quot;Colour&quot;></span></td>
      </tr>
      </tbody> 
    </table>
  </div>
  <p align=&quot;left&quot;>To simply illustrate the problem, the .csv file to go with this 
    page is as follows:</p>
  <p align=&quot;left&quot;>Letter,Colour<br>
    A,red<br>
    B,white<br>
    C,green </p>
  <p align=&quot;left&quot;>and is called alphabet.txt in the same folder/directory</p>
  <p align=&quot;left&quot;>I want to control the bgcolor or bgimage of the individual span with the color value 
    given in the csv / text file, as the table is written</p>
  </div>
</BODY>
</HTML>
 
i think you should detail more your problem in order to get help : what is not working ? is that you can't read the csv file ? or can you ? is that you can't retrieve values from this file ? or can you ? is that you don't know how to embed the read values in your hml page ? or can you ? is that only a ns/ie compatibility problem ? where do you get the problem ?
 
Hi IZA,
thanks for the reply.
I can read all the data from the .csv fine and it builds me a table into a new page just as I want it to, but what I also want to do is colour the background of certain cells within this table as the page/table is built. These certain cells are the ones for example where the data value is &quot;red&quot; i want to colour the cell, or even the text RED to highlight the entry as either new or important - so its easily visible straight away.
Do you see what I mean?

thanks

mac
 
ok, you build your page dynamically, but i still haven't understood WHERE is your problem
if you can write the &quot;<table><tr>....&quot; tags, and if you can read the datas, while writing <tr> add a condition on the data to set the bgcolor (i don't know which language you're using to write this ! so i'll use pseudo code) :
write(&quot;<tr&quot;)
if (data.value == &quot;A&quot;){
write(&quot; bgcolor='red'&quot;)
}
write(&quot;>&quot;)

 
The language I'm using is Javascript if it helps.
mac
 
so can you write a test as such :
---
document.write(&quot;<tr&quot;)
if (idont_know_where_you_stored_your_datas==&quot;A&quot;){
document.write(&quot; bgcolor='red'&quot;)
}
document.write(&quot;>&quot;)
---
??
 
Hi IZA,

Thanks for your help with my problem.... if been away and now will have a chance to try your last suggestion out.

I also now need to be able to read the last modified date of the data file ie: data.csv, so that I know when the file was last updated. This I need to put onto the web page as just a label/text etc.
That bit shouldnt be the problem... what I cant work out is how to perform a getDate type of function either through the databinding class or can I just do it from HTML or javascript by just enquiring the details of that file without get as deep as PARAM NAME= errmm whatever ?
It has to work in IE4 or 5 or 5.5.
Any ideas

Thanks
mac
 
mac, i hope my last solution will help - let me know

about the date problem, i don't know and might have to do some searching - but i don't have much much time, so i'd suggest you post your question on reading dates as a new thread as 1. it's a new subject/question anyway and 2. it'll be read by more person (as there's 0 answer), so you might get a quicker and more accurate answer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top