Skip navigation
Graham Calhoun
Currently Being Moderated

Change font color by javascript on exit

Jul 13, 2009 3:56 PM

I would like to change the font color of textfieldB when the user exits textfieldA by means of JS

 

Right now, I am using textfieldB.fontColor = "0,0,0"; (the font color is originally (255,0,0)

 

When I preview the form, nothing happens. No error in the console, no changing colors.

 

What am I doing wrong?

 

Graham

 
Replies
  • Currently Being Moderated
    Jul 13, 2009 7:50 PM   in reply to Graham Calhoun

    Hi Graham,

     

    Seems to work for me, I've attached a sample, hope that helps.

     

    Bruce

    Attachments:
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 14, 2009 6:14 AM   in reply to Graham Calhoun

    The issue is that the field you are trying to set is not a TextField but a regular Text object. The fontColor is not a valid property of that object. To get at the Text objects font color use this expression:

     

    PlainText.font.fill.color.value

    = "0,0,0";

     

    Paul

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 14, 2009 6:34 AM   in reply to Graham Calhoun

    Actually what I do is look at the XML source to see what path is being used to set the value ...then I merely duplicate it in the call. In the docs each property and method is defined ...you just need to know that color is a subset of fill etc.

     

    The fillcolor is a shortcut that was added to a TextField to make it easier than having to go through the whole path.

     

    Paul

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 14, 2009 7:15 AM   in reply to Graham Calhoun

    Yes we are ....once in the XML source you can click on an object in the hierarchy and the cursor will move to that definition. In the case of your Text object here is the XML that defines it:

     

    <

    draw name="PlainText" y="92.075mm" x="41.275mm" w="29.2864mm" h="5.2331mm">

         <

    ui>

              <

    textEdit/>

         </

    ui>

         <

    value>

              <

    text>Text</text>

         </

    value>

         <

    font typeface="Myriad Pro" baselineShift="0pt">

              <

    fill>

                   <

    color value="255,0,0"/>

              </

    fill>

         </

    font>

         <

    margin topInset="0.5mm" bottomInset="0.5mm" leftInset="0.5mm" rightInset="0.5mm"/>

         <

    para spaceAbove="0pt" spaceBelow="0pt" textIndent="0pt" marginLeft="0pt" marginRight="0pt"/>

    </

    draw>

    Note that the name attribute of the draw is "PlainText". Then below that we have a font definition ....so following the hierarchy of the XML we get:

     

    PlainText.font.fill.color.value

     

    In some case the value attribute is implied and in others it is stated in the structure. If I wanted to get at the text that is being displayed I would use:

     

    PlainText.value.text.value

     

    Make sense?

     

    Paul

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 14, 2009 10:49 AM   in reply to pguerett

    Great tip - thanks Paul!

     

    Makes understanding what's going on much easier.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points