I want to render a list and then set the background colour of these lists
depending on what is selected.

.page
<SNIP>
    <property-specification name="questions" type="java.util.List"
persistent="yes"/>
    <property-specification name="question"
type="xxxxxxxxxx.businessObjects.Question"/>
</SNIP>

.html
<SNIP>
function setCorrectColor(obj) {
        obj.style["color"]="white";
        if (obj.value=="0") {
                obj.style["backgroundColor"]="red";
        } else if (obj.value=="1") {
                obj.style["backgroundColor"]="#00A000";
        } else if (obj.value=="2") {
                obj.style["backgroundColor"]="#009000";
        } else if (obj.value=="3") {
                obj.style["backgroundColor"]="#007000";
        } else if (obj.value=="4") {
                obj.style["backgroundColor"]="#005000";
        }
}
</SNIP>

<SNIP>
<TD>
<SELECT id="achievedChoice" jwcid="achievedChoice"
onchange="setCorrectColor(this)" />
</TD>
</SNIP>

The only way I can make this happen at Render time is using the "id" I added
to the page above:

.html
<SNIP> // Added at the bottom of the page so that it runs after the page is
elaborated
<SCRIPT language="JavaScript" type="text/javascript">
        var elements = document.getElementsByName("achievedChoice");
        for (elementCount=0;elementCount<elements.length;elementCount++) {
                setCorrectColor(elements[elementCount]);
        }
        </SCRIPT>
        </SPAN>
</BODY>
</SNIP>

Anyone think of a better way to achieve this, I would be interested as this
doesn't work on Firefox... as Firfox does not pick up the "id's" as
allowable when calling document.getElementsByName("achievedChoice"); which I
believe is actually pretty correct...

Points to javascript needing a pre-and post render event for an element.


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.11/191 - Release Date: 2/12/2005
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to