Forums

checbox selections change color

treybraid 17 May, 2014
http://xtreme-traction.com/YOUTH/free-publications.html

On my form what would I need to add; so, when an object is chosen or text fields filled out it changes to a set color when the results are emailed?

Example:
HCYR Corral newsletter yes
HCYR information packet no
Hill Country Youth Ranch compilation DVD no
Big Springs Ranch for Children compilation DVD no
Macaroni at Midnight no
Prisoner of the Clay CD none
Poetry books by children none
Name William H Braid III
Mailing Address 1830 Whitney Street
Home phone 706.736.1557
Cell phone 706.550.2889
Email trey.braid@email.com
GreyHead 18 May, 2014
Hi Trey,

To change the colour in the form when an item is checked you'd need to use JavaScript to alter the CSS styling for that ite,

To change the colour in an email you'd need to use PHP in a Custom Code action also to change the CSS styling of the element.

Bob
treybraid 18 May, 2014
What would the code be for each? Trey
treybraid 18 May, 2014
I'm really just concerned with the form when it's delivered in email.
GreyHead 18 May, 2014
Hi Trey,

It's impossible to say what the code *should* be; this is a form using your custom HTML and a custom Email template. I guess that the minimum to change the color would be two change the CSS for that line.
<?php
$email_template = array();
$color = 'black';
if ( $form->data['some_input'] == 'yes' ) {
  $color = 'red';
}
$email_template[] = "<p style='color: {$color};'>Some text here</p>";
// repeat as necessary
$form->data['email_template'] = implode("/n", $email_template);
?>
treybraid 18 May, 2014
Considering I had no idea what you were telling me yesterday...I guess just adding this code will not take care of the issue and I'd still be at square 1 trying to figure this and that out.

Thanks for helping and sorry I just don't understand this completely...
Trey
GreyHead 19 May, 2014
Hi Trey,

Like most of the code posted here it's an example. You need to adapt it to your particular form elements. In $form->data['some_input'] you need to replace some_input with the name of an input in your form.

Where it says some text here that needs to be replaced with the text you want to show in your email.

Where it says //repeat as necessary then you can repeat the preceding chunk of code if you need to format more than one form input.

Bob
treybraid 19 May, 2014
...that's the problem Bob, I don't understand what I should put for some_input.

Thanks
Trey
GreyHead 19 May, 2014
Hi Trey,

As I've already said . . . the name of an input in your form

Each input has a name.

Bob
treybraid 19 May, 2014
ok do i need to put an "_" before it or just the field name?

thanks for your patience
trey
GreyHead 20 May, 2014
Hi Trey,

Just the field name.

Bob
This topic is locked and no more replies can be posted.