This topic is locked

Change Field Colour Depending On Selected Answer

11/28/2008 10:48:49 PM
PHPRunner General questions
B
bochaka author

I have a field which the user selects either yes or no from a dropdown. How can I have the field background colour of the cell for that particular field change to red if the user selects no from the dropdown. Also I love the new appearence for the site support area but where has the link to this forum gone.

J
Jane 12/1/2008

Hi,
use custom JavaScript code for this purpose.

Here is a sample:

<script>

document.forms.editform.value_FieldName.onchange=function()

{

if(this.options[this.selectedIndex].value=="no")

document.forms.editform.value_FieldName.style.backgroundColor="red";

else

document.forms.editform.value_FieldName.style.backgroundColor="white";
}

</script>



To add JavaScript proceed to the Visual Editor tab, switch to HTML mode and add ode at the end of the page.

B
bochaka author 12/1/2008

Many thanks.

M
mengo 12/2/2008

Hi,

use custom JavaScript code for this purpose.

Here is a sample:
To add JavaScript proceed to the Visual Editor tab, switch to HTML mode and add ode at the end of the page.


Hi Jane,

Pardon my newbieness

How can I do it(Change Field Color/Preferable cell color depending on field value) for field values rather than drop down?
Thanks in advance

J
Jane 12/2/2008

Hi,
see my changes in Bold:

<script>

document.forms.editform.value_FieldName.onchange=function()

{

if(document.forms.editform.value_FieldName.value=="no")

document.forms.editform.value_FieldName.style.backgroundColor="red";

else

document.forms.editform.value_FieldName.style.backgroundColor="white";
}

</script>

M
mengo 12/3/2008

Hi,

see my changes in Bold:


Jane thank you for reply.

I tried but nothing changed. Probably I didn't do it correctly.

What do I have to change in this script. I changed FieldName to my field name(e.g itemapproved) which I want to change color...
So, basically I want to change cell color depending on field value(e.g Yes or No).

Could you tell me what I should do?
Thanks in advance

J
Jane 12/3/2008

Hi,
it's just a sample code.

You need to replace field names with your actual ones. Also please make sure your field values are correct. Values are case-sensitive here.
If it doesn't help publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages.

M
mengo 12/5/2008

Hi,

it's just a sample code.

You need to replace field names with your actual ones. Also please make sure your field values are correct. Values are case-sensitive here.
If it doesn't help publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages.


Jane,

Again thanks for your help. Before uploading to demo account I wanted to make sure that I'm doing right thing.

In List Page, I have table containing tracking info ,which is filled by different users. User1(shipper) adds records and left side of table contains shipping info. User2(receiver) adds records when receives item. So, I want to change color of the particular row, which has not receiving info(item is not received yet).
So, does this script apply to my request?

If yes, could you please make bold fields names, which should be changed?
Many thanks

J
Jane 12/5/2008

Hi,
this code is for add/edit pages.

To change row background color on the list page use List page: After record processed event on the Events tab:

if ($data["FieldName"]=="no")

$row["rowstyle"]='style="background:blue"';

M
mengo 12/5/2008

Hi,

this code is for add/edit pages.

To change row background color on the list page use List page: After record processed event on the Events tab:


Jane,

Thank you very much.

Now it works