Jump to content
  • 0

Dynamically change the background of a row


Michitect

Question

Only the first content in my list (for example with the word "Aangeworven") dynamically changes the background color of the row.

What should I do if I want to change ALL the lines to green, with the content "Aangeworven"?

 

<a id="visi[@field:Status]">
<script>
var isi = document.getElementById("visi[@field:Status]");
if('[@field:Status]' == 'Aangeworven'){
isi.parentNode.parentNode.style.backgroundColor = '#b3e6b3';
}
if('[@field:Status]' == 'Te scouten'){
isi.parentNode.parentNode.style.backgroundColor = '#ffdab3';
}
if('[@field:Status]' == 'Afgekeurd'){
isi.parentNode.parentNode.style.backgroundColor = '#ffb3b3';
}
</script>

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
On 9/20/2016 at 8:41 PM, Michitect said:

Only the first content in my list (for example with the word "Aangeworven") dynamically changes the background color of the row.

What should I do if I want to change ALL the lines to green, with the content "Aangeworven"?

 

<a id="visi[@field:Status]">
<script>
var isi = document.getElementById("visi[@field:Status]");
if('[@field:Status]' == 'Aangeworven'){
isi.parentNode.parentNode.style.backgroundColor = '#b3e6b3';
}
if('[@field:Status]' == 'Te scouten'){
isi.parentNode.parentNode.style.backgroundColor = '#ffdab3';
}
if('[@field:Status]' == 'Afgekeurd'){
isi.parentNode.parentNode.style.backgroundColor = '#ffb3b3';
}
</script>

Hi Michitect,

I suppose, you need to leave only the first 'if' statement:

<a id="visi[@field:Status]">
<script>
var isi = document.getElementById("visi[@field:Status]");
if('[@field:Status]' == 'Aangeworven'){
isi.parentNode.parentNode.style.backgroundColor = '#b3e6b3';
}

</script>

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...