+ Post New Thread
Results 1 to 3 of 3
Coding Thread, HTML Table, change cell colour on value entered in Coding and Web Development; Hello, This is probably very easy for web developers or coders out there but i aint got a clue, hope ...
  1. #1

    Join Date
    Oct 2007
    Location
    scotland
    Posts
    45
    Thank Post
    15
    Thanked 1 Time in 1 Post
    Rep Power
    0

    HTML Table, change cell colour on value entered

    Hello,

    This is probably very easy for web developers or coders out there but i aint got a clue, hope someone can help.

    I have an asp web page with a table. The table consists of 2 columns, target grade and now grade for each pupil for a subject.

    A teacher will enter a target grade say 2, and then at a predetermined month enter the pupils actual "now" grade but instead of being easy and entering 2 or 1 or 3 or whatever they want to enter +1 or -1 or 0. This bit is fine.

    The bit i need help for is this: depending on what value is entered in the table cell, the cell background colour is to change.
    eg +1 = BLUE
    0 = GREEN
    -1 = RED

    Can anyone help? I am thinking it might be an IF statement i need but i do not have a clue.

    Heres the code i have so far: Thanks in advance!

    h4><font color="#000000">English:</h4>
    <table border="1">
    <tr>
    <th></th>
    <th colspan="2">Dec S3</th>
    <th colspan="2">Apr S3</th>
    <th colspan="2">Nov S4</th>
    <th colspan="2">Feb S4</th>
    </tr>
    <tr>
    <td>Initial Target</td>
    <td>Target</td>
    <td>Now</td>
    <td>Target</td>
    <td>Now</td>
    <td>Target</td>
    <td>Now</td>
    <td>Target</td>
    <td>Now</td>
    </tr>
    <td><input type="text" style="font-family: Times New Roman; font-size: 14pt" size="4" name="engtarget" value="<%=RSlist2("engtarget")%>"</td>
    <td><input type="text" style="font-family: Times New Roman; font-size: 14pt" size="4" name="edecs3t" value="<%=RSlist2("edecs3t")%>"</td>
    <td><input type="text" style="font-family: Times New Roman; font-size: 14pt" size="4" name="edecs3n" value="<%=RSlist2("edecs3n")%>"</td>
    <td><input type="text" style="font-family: Times New Roman; font-size: 14pt" size="4" name="eaprs3t" value="<%=RSlist2("eaprs3t")%>"</td>
    <td><input type="text" style="font-family: Times New Roman; font-size: 14pt" size="4" name="eaprs3n" value="<%=RSlist2("eaprs3n")%>"</td>
    <td><input type="text" style="font-family: Times New Roman; font-size: 14pt" size="4" name="enovs4t" value="<%=RSlist2("enovs4t")%>"</td>
    <td><input type="text" style="font-family: Times New Roman; font-size: 14pt" size="4" name="enovs4n" value="<%=RSlist2("enovs4n")%>"</td>
    <td><input type="text" style="font-family: Times New Roman; font-size: 14pt" size="4" name="efebs4t" value="<%=RSlist2("efebs4t")%>"</td>
    <td><input type="text" style="font-family: Times New Roman; font-size: 14pt" size="4" name="efebs4n" value="<%=RSlist2("efebs4n")%>"</td>
    <tr>

    </table>

    Miller

  2. #2
    SteveBentley's Avatar
    Join Date
    Jun 2007
    Location
    Yorkshire
    Posts
    1,446
    Thank Post
    120
    Thanked 263 Times in 189 Posts
    Rep Power
    72
    gonna be a Javascript job, probably something along the lines of the following, in your input tag

    onchange="if (this.value=='+1')this.className='bluebg';if (this.value=='-1')this.className='redbg';if (this.value=='0')this.className='greenbg';"

    with bluebg, redbg and greenbg all set up as styles in your CSS with the appropriate backgrounds.

  3. #3

    HarryMonkey's Avatar
    Join Date
    Mar 2007
    Location
    Bedford
    Posts
    1,157
    Thank Post
    59
    Thanked 222 Times in 168 Posts
    Rep Power
    174

SHARE:
+ Post New Thread

Similar Threads

  1. change heading colour for each page
    By PEO in forum EduGeek Joomla 1.5 Package
    Replies: 1
    Last Post: 13th February 2009, 12:21 AM
  2. Change Desktop Colour
    By DaveP in forum How do you do....it?
    Replies: 12
    Last Post: 19th January 2009, 12:43 PM
  3. Change background colour...
    By RTi in forum EduGeek Joomla 1.5 Package
    Replies: 1
    Last Post: 8th October 2008, 01:01 PM
  4. VB code to colour cells in a word table
    By park_bench in forum Coding
    Replies: 4
    Last Post: 30th June 2008, 08:52 AM
  5. Excel Cell colour changes
    By wesleyw in forum How do you do....it?
    Replies: 3
    Last Post: 20th December 2006, 10:01 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •