Copy link to clipboard
Copied
I have a similar question as one of the forum users who ask about auto-populating a scholarship selection criteria text after user select the type of scholarship from a drop-down. Unfortunately that question was not answered. For my case, I am developing a continued education event invitation. Based on the selection from the drop-down list for the course title, I want a course description (around 100 words) to auto-populated in a separate text box. There is a word limit on the drop down list so I cannot accomplish what I need to do on a drop-down list itself. I browsed at the past forum and came close to a javascript solution. I don't know javascript so I cannot modify that solution for my case. I saw from the actions tab there is an option for import form data. Will that option help me to do what I need? Greatly appreciate it!
Copy link to clipboard
Copied
You can do it using a script. As the custom validation script of your drop-down you can use something like this:
if (event.value=="Course 1") this.getField("CourseDescription").value = "Course 1 description...";
else if (event.value=="Course 2") this.getField("CourseDescription").value = "Course 2 description...";
else if (event.value=="Course 3") this.getField("CourseDescription").value = "Course 3 description..."; // etc.
else this.getField("CourseDescription").value = "";
Make sure you tick the option to commit the value of the drop-down field immediately so that the text field will update as soon as a selection is made.
Copy link to clipboard
Copied
You can do it using a script. As the custom validation script of your drop-down you can use something like this:
if (event.value=="Course 1") this.getField("CourseDescription").value = "Course 1 description...";
else if (event.value=="Course 2") this.getField("CourseDescription").value = "Course 2 description...";
else if (event.value=="Course 3") this.getField("CourseDescription").value = "Course 3 description..."; // etc.
else this.getField("CourseDescription").value = "";
Make sure you tick the option to commit the value of the drop-down field immediately so that the text field will update as soon as a selection is made.
Copy link to clipboard
Copied
Thank you very much! It works!
Now, I have a similar question but it involves pictures. Can I do similar script for pictures? I need to auto-populate the speakers' bio (text) and head shots (photos) based on the speaker selection from another drop-down list. Thank you very much in advance!
Copy link to clipboard
Copied
Yes, you can do that. The trick is to use button fields to hold the images and then show/hide them based on the selection made.
So let's say you have a button called Image1 and you want to show it when Course 1 is selected (and hide it when it's not, of course). You can use something like this as your validation code:
this.getField("Image1").display = (event.value=="Course 1") ? display.visible : display.hidden;
Copy link to clipboard
Copied
How do I hold the image in the button function? I explore different tabs but do not seem to find somewhere I can upload an image. Thanks again!
Copy link to clipboard
Copied
Never mind. Figured it out, using icon.
Copy link to clipboard
Copied
How do I add the logic "AND" in the script?
if (event.value=="Susan Smith") this.getField("SpeakerTitle").value = "Renal Program Education Manager")
I need to add a parallel condition if user chooses Susan, to populate her bio in another text box :
AND
this.getField("SpeakerBio").value = "Susan ..........";
I use AND, then try to use parentheses in various places but still have get an error message
Thanks again!
Copy link to clipboard
Copied
No, AND (&&) is a logical operator and only used in conditions, not for executing multiple statements. What you're after is a block of code that is associated with the if-function. To do that place your code between curly brackets, like this:
if (event.value=="Susan Smith") {
this.getField("SpeakerTitle").value = "Renal Program Education Manager");
this.getField("SpeakerBio").value = "Susan ..........";
}
Copy link to clipboard
Copied
Thank you very much try67 for all your help! I am able to create the document exactly what I aim to do! Greatly appreciate it!
Copy link to clipboard
Copied
Hi Try! I used your calculation and it worked for the first two selections, but not for the other 33 I have. Each of my drop down options will need to populate a text field with a bout 124 characters, but for some reason this formula only works for the first two options. Do you know why? I need help! Thanks!
Copy link to clipboard
Copied
No, how can I without seeing the file? Check the JS Console for error messages, for starters.
Copy link to clipboard
Copied
This is the formula I am using...it's long!
// if (event.value=="1 month")this.getField("SocialSkillsCASnapshot").value = "Snapshot of 1 month old babies in this area: Babies enjoy looking at faces and will brighten when talked to. They enjoy touch and being held by familiar adults. Babies recognize their moms by smell, touch, voice and face. They may already start to engage in vocal turn taking. Babies express feelings by cooing, gurgling and crying. They are learning how to internalize strategies for self-soothing."; else if (event.value=="2 months") this.getField("SocialSkillsCASnapshot ").value = "Snapshot of 2 month old babies in this area: Babies will now react to caregivers by smiling, vocalizing and moving their arms and legs vigorously with excitement to interact. They enjoy watching faces and are very responsive to facial expressions, movements and tone of voice. Babies enjoy touch and being held by familiar adults. Crying diminishes with eye contact from a caregiver and they maintain eye contact when socializing. Their ability to self soothe is improving. They express feelings by cooing, gurgling and crying."; else if (event.value=="3 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 3 month old babies in this area: Babies enjoy touch and being held by familiar adults. They are now regularly smiling and cooing during face-to-face interactions and have a strong attachment to primary caregivers. They will maintain eye contact as they take turns vocalizing to socialize with caregivers. They may even copy some facial expressions. Babies have special smiles just for parents/caregivers and may show signs of distress if handled by an unfamiliar adult. They express feelings by cooing, gurgling and crying."; else if (event.value=="4 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 4 month old babies in this area: Babies are very interested in socializing with familiar people using their voice. They will take turns making sounds and copy facial expressions. They now expect and elicit responses from others. They are starting to recognize unfamiliar people and places. They become excited at new and different toys. They are now showing pleasure/ displeasure by vocalizing and may even laugh. If they are crying, they will often stop when their caregivers talk to them."; else if (event.value=="5 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 5 month old babies in this area: Babies are becoming even more social. They are starting to interact with caregivers for reasons other than for comfort and security. They will more often initiate interactions by maintaining eye contact while smiling and vocalizing at parents and other familiar people. They are beginning to play along with baby games like tickles, peek-a-boo and pat-a-cake. Babies can distinguish between friendly and angry voices. They are showing pleasure and displeasure through vocalizing and they may even laugh. When crying, they will often stop if a caregiver talks to them."; else if (event.value=="6 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 6 month old babies in this area: Babies are very interested in being with people. They are now responsive to facial expressions (smiling to smiles; becoming upset to angry expressions). They will engage adults by using their voice, waving and reaching. They will turn immediately upon hearing Mom’s or Dad’s voice across the room. Babies may protest separation from primary caregivers and need time to study new people. Stranger anxiety may be present. Babies will coo, babble and smile when socializing if happy, and vocalize displeasure when unhappy. They now enjoy looking in the mirror and will smile at their image."; else if (event.value=="7 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 7 month old babies in this area: Babies are very interested in being with people. They are now responsive to facial expressions (smiling to smiles; becoming upset to angry expressions). Babies are more often engaging others socially through eye contact and gestures, (like holding their arms up to be picked up or pushing things away to protest). They will squeal, giggle and call out to get attention. Stranger anxiety may still be present, with babies clinging to mom or dad if someone unfamiliar approaches. Babies may show fleeting interest in other babies, but interactions will typically be limited to a coo or a grab."; else if (event.value=="8 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 8 month old babies in this area: Babies are very interested in being with people. They continue to increase their ability to vocalize in ‘conversation’ as they engage with their caregivers using gestures and maintaining eye contact. They start to initiate social games like peek-a-boo. Babies use gestures and vocalizations to protest as well as make requests. Babies are very attached to caregivers. First stranger anxiety may be resolving. Babies may show fleeting interest in other babies, but interactions will typically be limited to a coo or a grab."; else if (event.value=="9 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 9 month old babies in this area: Babies now look at parent’s face and expression if they need information about a new situation or person. They focus their attention more on objects that others are focused on too (joint attention). They engage parents with smiles and back and forth sound play as they maintain eye contact. Babies will repeat actions if their parents laugh at them. They will turn their head when their name is called. Babies may be starting to use social gestures to interact with others: waving, holding toys up to show others, looking back at others to ‘request’, and pushing away to protest/ refuse. Babies may show fleeting interest in other babies, but interactions will typically be limited to a coo or a grab."; else if (event.value=="10 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 10 month old babies in this area: Babies now look at parent’s face and expression if they need information about a new situation or person. They more often focus their attention on objects that others are focused on too (joint attention). They maintain eye contact when engaging in turn-taking and social games like peek-a-boo. Babies may imitate gestures, sounds or words. They are starting to respond to ‘no’ and will briefly stop. They show sensitivity to the mood of others and may cry if others are crying. Babies are using gestures and their voice to interact with others: waving, holding toys up to show others, looking back to ‘request’ and pushing away to protest/refuse. Babies may show fleeting interest in other babies, but interactions will typically be limited to a coo or a grab."; else if (event.value=="11 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 11 month old babies in this area: Babies now look at parent’s face and expression if they need information about a new situation or person. They can focus their attention on objects/activities that others are focused on too (joint attention). Babies participate in social games like peek a boo, maintaining eye contact, using gestures and their voice. They are starting to respond to ‘no’ and will briefly stop when it is heard. Showing sensitivity to others’ moods is present and they will express at least two emotions (pleasure, fear, sadness, etc.) through facial expressions and body language. Babies interact with others by waving, holding toys up to show them, looking back at others to ‘request’ and pushing away to protest. They will show interest in other babies, including coos, grabs, smiles and may even attempt to imitate another baby’s sounds."; else if (event.value=="12 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 12 month old babies in this area: Babies still enjoy sharing their focus on an object/activity with a caregiver, but they are also becoming more independent and autonomous. They will start to test limits; this helps them learn rules and consequences of breaking them. They may hand toys to mom or dad when asked. Babies will spend time watching what other babies are doing and may even imitate them. They maintain eye contact as well as use gestures and their voice to greet, request, comment and protest/refuse. They may even be saying their first words socially. They show sensitivity to the mood of others and will express at least two emotions (pleasure, fear, sadness, etc.) through facial expression and body language."; else if (event.value=="13 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 13 month old children in this area: Children enjoy sharing their focus on an object/activity with a caregiver but they are becoming more independent and autonomous. They will test limits; this helps them learn rules, and the consequences of breaking them. They also start following directions to please adults. Children are using gestures and their voice often to request, comment and protest/refuse and even respond to adult conversational attempts-even if their responses may be off topic. They will maintain eye contact as they socialize with others using babbles, jargon and a few early words. Children will spend time watching what other children are doing and may even imitate them. They will show awareness of the feelings of others, maybe even crying if someone else is sad."; else if (event.value=="14 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 14 month old children in this area: Children will show affection to mom and dad by giving them hugs and kisses. They may also hug stuffed animals or dolls. They want to be near adults and will engage in social games to please them. Children will seek out opportunities to share attention on an object or activity with caregivers (story time, etc.). They are aware of, and interested in, peers but tend to watch and imitate what they see other kids do rather than interact with them. Children will maintain eye contact as they use gestures, jargon and some words to make requests, comments, protest/refuse, and respond to what others say to them. They will show awareness of the feelings of others.”; else if (event.value=="15 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 15 month old children in this area: Children are starting to be more comfortable playing away from familiar people but will retreat to caregivers if an unfamiliar adult approaches. They maintain eye contact as they use words, gestures and some jargon to request, comment, protest/refuse and respond to what others say. They enjoy shared experiences with adults; but attention span is short. They may be hardest on the caregiver they depend on the most. They are aware of, and interested in peers, but tend to watch and imitate what they see other kids do rather than interact with them as they are still quite self-focused. Temper tantrums are emerging.”; else if (event.value=="16 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 16 month old children in this area: Children are imitating grown up activities, possibly pretending to talk on the phone or wipe down a table. They enjoy engaging with adults and doing activities to please them. When socializing, they will use gestures and words to “talk” to others while maintaining eye contact and shared affect (emotion). They communicate to make requests, comments, refusals and respond to what other say. Children may get anxious around strangers and prefer to be near caregivers. They are aware of, and interested in peers, but tend to watch and imitate what they see other kids do rather than interact with them as they are still quite self-focused."; else if (event.value=="17 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 17 month old children in this area: Children enjoy engaging with adults and doing activities to please them. They are now able to share their focus on an object/activity with a caregiver for longer periods of time. They use eye contact, gestures and some words when making requests, comments, protest/refusals, when responding to others and when expressing their feelings. They are aware of and very interested in other children. They will play near them using similar toys in similar ways. On occasion, they may compete for a toy with another child. This is a critical period where children begin to understand that people exist and there is a whole world they can interact with."; else if (event.value=="18 months") this.getField("SocialSkillsCASnapshot").value = “Snapshot of 18 month old children in this area: Children are using words more often to make requests, comments, protest/refuse, greet and respond to others while maintaining eye contact as they interact socially. Children are now often found playing near each other with similar toys. They may bite, hit, scratch or pull hair if overwhelmed and unable to express this frustration with words. Pushing limits, saying ‘no’ and tantrums are all part of children’s development at this age. They may express more complex emotions such as fear, sympathy, modesty, guilt and embarrassment through facial expression and body language more so than words. They can now predict that a broken toy will make another child unhappy. They may attempt to change the other child’s affect by offering a suitable toy. "; else if (event.value=="19 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 19-21 month old children in this area: Children frequently use their words to communicate with others as they make comments/tell info, make requests, respond to others and even attempt to initiate pretend play. They know that it’s important to look at other people as they talk to them. Children have a better understanding of others’ feelings. They will now try to comfort others if they are distressed. Increasing independence allows them to move away from parents and sit with other familiar adults. Children will exhibit varying emotions in play; they may even be seen scolding stuffed animals/dolls. They are interested in playing with other children and can play with similar toys in similar ways near their peers, but may not be able to share yet.”; else if (event.value=="20 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 19-21 month old children in this area: Children frequently use their words to communicate with others as they make comments/tell info, make requests, respond to others and even attempt to initiate pretend play. They know that it’s important to look at other people as they talk to them. Children have a better understanding of others’ feelings. They will now try to comfort others if they are distressed. Increasing independence allows them to move away from parents and sit with other familiar adults. Children will exhibit varying emotions in play; they may even be seen scolding stuffed animals/dolls. They are interested in playing with other children and can play with similar toys in similar ways near their peers, but may not be able to share yet."; else if (event.value=="21 months") this.getField("SocialSkillsCASnapshot").value = " Snapshot of 19-21 month old children in this area: Children frequently use their words to communicate with others as they make comments/tell info, make requests, respond to others and even attempt to initiate pretend play. They know that it’s important to look at other people as they talk to them. Children have a better understanding of others’ feelings. They will now try to comfort others if they are distressed. Increasing independence allows them to move away from parents and sit with other familiar adults. Children will exhibit varying emotions in play; they may even be seen scolding stuffed animals/dolls. They are interested in playing with other children and can play with similar toys in similar ways near their peers, but may not be able to share yet."; else if (event.value=="22 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 22-24 month old children in this area: Children are using many words, and possibly 2-word phrases, along with eye contact to request, comment, greet, protest, etc... They are developing a sense of self, now using ‘mine’ and are claiming everything as their own. They are interested in playing with other children and do well when playing with similar toys in similar ways near their peers, but may still have difficulty sharing toys. They will start to imitate routines that they see in everyday life in their play. Children show a wide variety of emotions, including jealousy-especially concerning family members. They now understand that others get happy when they get something and sad when they don’t. They may attempt to comfort others when they see that they are distressed."; else if (event.value=="23 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 22-24 month old children in this area: Children are using many words, and possibly 2-word phrases, along with eye contact to request, comment, greet, protest, etc... They are developing a sense of self, now using ‘mine’ and are claiming everything as their own. They are interested in playing with other children and do well when playing with similar toys in similar ways near their peers, but may still have difficulty sharing toys. They will start to imitate routines that they see in everyday life in their play. Children show a wide variety of emotions, including jealousy-especially concerning family members. They now understand that others get happy when they get something and sad when they don’t. They may attempt to comfort others when they see that they are distressed."; else if (event.value=="24 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 22-24 month old children in this area: Children are using many words, and possibly 2-word phrases, along with eye contact to request, comment, greet, protest, etc... They are developing a sense of self, now using ‘mine’ and are claiming everything as their own. They are interested in playing with other children and do well when playing with similar toys in similar ways near their peers, but may still have difficulty sharing toys. They will start to imitate routines that they see in everyday life in their play. Children show a wide variety of emotions, including jealousy-especially concerning family members. They now understand that others get happy when they get something and sad when they don’t. They may attempt to comfort others when they see that they are distressed."; else if (event.value=="25 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 25-27 month old children in this area: Children are now combining words to make requests, comments, greet others, protest/refuse, acknowledge others and respond to information said to them. They understand that looking at someone is important when you talk with them. They are developing a strong sense of independence and might become easily frustrated if they are unable to do something themselves. Children may start to express modesty, pity and shame through facial expressions and body language. Their interest in other children continues to grow and they are now able to offer toys and initiate play with others (although the play may not always be successful). They are aware of how others feel and understand that others get happy when they get something, and sad when they don’t."; else if (event.value=="26 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 25-27 month old children in this area: Children are now combining words to make requests, comments, greet others, protest/refuse, acknowledge others and respond to information said to them. They understand that looking at someone is important when you talk with them. They are developing a strong sense of independence and might become easily frustrated if they are unable to do something themselves. Children may start to express modesty, pity and shame through facial expressions and body language. Their interest in other children continues to grow and they are now able to offer toys and initiate play with others (although the play may not always be successful). They are aware of how others feel and understand that others get happy when they get something, and sad when they don’t."; else if (event.value=="27 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 25-27 month old children in this area: Children are now combining words to make requests, comments, greet others, protest/refuse, acknowledge others and respond to information said to them. They understand that looking at someone is important when you talk with them. They are developing a strong sense of independence and might become easily frustrated if they are unable to do something themselves. Children may start to express modesty, pity and shame through facial expressions and body language. Their interest in other children continues to grow and they are now able to offer toys and initiate play with others (although the play may not always be successful). They are aware of how others feel and understand that others get happy when they get something, and sad when they don’t."; else if (event.value=="28 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 28-30 month old children in this area: Children are now combining words to make requests, comments, greet others, protest/refuse, acknowledge others and respond to information said to them. They are better able to relate simple imaginative tales and will even misrepresent reality (fib, tease). They know that looking at someone is important when you talk with them. They are very interested in playing alongside peers and more often talk in short phrases as they share toys during pretend play. They will express emotions of pity, shame and modesty through their behavior and facial expressions. They understand that others get happy when they get something, and sad when they don’t.";else if (event.value=="29 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 28-30 month old children in this area: Children are now combining words to make requests, comments, greet others, protest/refuse, acknowledge others and respond to information said to them. They are better able to relate simple imaginative tales and will even misrepresent reality (fib, tease). They know that looking at someone is important when you talk with them. They are very interested in playing alongside peers and more often talk in short phrases as they share toys during pretend play. They will express emotions of pity, shame and modesty through their behavior and facial expressions. They understand that others get happy when they get something, and sad when they don’t."; else if (event.value=="30 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 28-30 month old children in this area: Children are now combining words to make requests, comments, greet others, protest/refuse, acknowledge others and respond to information said to them. They are better able to relate simple imaginative tales and will even misrepresent reality (fib, tease). They know that looking at someone is important when you talk with them. They are very interested in playing alongside peers and more often talk in short phrases as they share toys during pretend play. They will express emotions of pity, shame and modesty through their behavior and facial expressions. They understand that others get happy when they get something, and sad when they don’t."; else if (event.value=="31 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 31-33 month old children in this area: Children are now using phrases to talk about absent objects, remote events and even misrepresenting reality (teasing, fibs) in addition to communicating for more basic functions. They engage in conversation with both adults and peers. Interactive play with other children occurs frequently and they may even verbalize a play plan to others (e.g., “I’m mommy; you be baby"). They will express emotions like pity, shame and modesty through their behavior and facial expressions. They may use words like “happy”, ”sad”, “mad” or “scared” to talk about how they, or others, feel. They take pride in their achievements."; else if (event.value=="32 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 31-33 month old children in this area: Children are now using phrases to talk about absent objects, remote events and even misrepresenting reality (teasing, fibs) in addition to communicating for more basic functions. They engage in conversation with both adults and peers. Interactive play with other children occurs frequently and they may even verbalize a play plan to others (e.g., “I’m mommy; you be baby"). They will express emotions like pity, shame and modesty through their behavior and facial expressions. They may use words like “happy”, ”sad”, “mad” or “scared” to talk about how they, or others, feel. They take pride in their achievements."; else if (event.value=="33 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 31-33 month old children in this area: Children are now using phrases to talk about absent objects, remote events and even misrepresenting reality (teasing, fibs) in addition to communicating for more basic functions. They engage in conversation with both adults and peers. Interactive play with other children occurs frequently and they may even verbalize a play plan to others (e.g., “I’m mommy; you be baby"). They will express emotions like pity, shame and modesty through their behavior and facial expressions. They may use words like “happy”, ”sad”, “mad” or “scared” to talk about how they, or others, feel. They take pride in their achievements."; else if (event.value=="34 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 34-36 month old children in this area: Children now converse in sentences and attempt to control situations verbally. They respond to requests to clarify information and will continue topics by adding new information. They understand the importance of looking at people when they socialize. Words like “happy”, “sad”, “mad” and “scared” are used to talk about how they are feeling. Emotions may shift suddenly as they learn to handle them. Children think about the feelings of others; they may only be able to relate emotionally if they share the same perspective as the other person. They can participate in circle or interactive games with their friends. They tend to be dictatorial and demanding at this age."; else if (event.value=="35 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 34-36 month old children in this area: Children now converse in sentences and attempt to control situations verbally. They respond to requests to clarify information and will continue topics by adding new information. They understand the importance of looking at people when they socialize. Words like “happy”, “sad”, “mad” and “scared” are used to talk about how they are feeling. Emotions may shift suddenly as they learn to handle them. Children think about the feelings of others; they may only be able to relate emotionally if they share the same perspective as the other person. They can participate in circle or interactive games with their friends. They tend to be dictatorial and demanding at this age."; else if (event.value=="36 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 34-36 month old children in this area: Children now converse in sentences and attempt to control situations verbally. They respond to requests to clarify information and will continue topics by adding new information. They understand the importance of looking at people when they socialize. Words like “happy”, “sad”, “mad” and “scared” are used to talk about how they are feeling. Emotions may shift suddenly as they learn to handle them. Children think about the feelings of others; they may only be able to relate emotionally if they share the same perspective as the other person. They can participate in circle or interactive games with their friends. They tend to be dictatorial and demanding at this age."; // else this.getField("SocialSkillsCASnapshot").value = "";
Copy link to clipboard
Copied
- Remove the "//" at the start and end of the code. That makes it into a comment...
- If you use straight double-quotes within a string that's delimited by that kind of quotes then you have to escape them, by adding a backspace before them. That's not needed in the places where you use curly quotes, though.
I found at least one instance of this happening, here:
you be baby"
Edit: Fixed small mistake
Copy link to clipboard
Copied
When I don't have the // in the begininging, I get a Syntax Error, missing " before statement 1: at line 2. So far I have removed the // from the begininging and changed all of the quotes in the text to ' " i.e 'I'm the mommy, you be baby'). I have posted my question in a forum here: Calculating months between two dates to then populate multiple text fields. This is exactly what I want, but not sure if you can help me. You seem to really know your stuff!!
Copy link to clipboard
Copied
After changing all the quotes your code should be fine, as far as I can see.
I saw your other question. You're asking for a lot, though. There are tutorial online and several examples on these forums how to perform such time calculations, but it's not a simple task. You seem to have gotten the second part of your questions answered, though, with this code.
Copy link to clipboard
Copied
If I can't get the month's calculated that is fine, but I need to populate three different text boxes with different text based on the drop down of the months. I am still getting an error in this script, that I am missing a semicolon somewhere. But if I add // to the begining on the statement it goes through but still does not populate. I've removed all quotations marks and semicolons within the text, so really not sure what to do now. I am putting this in the run custom validation script under the validate tab on the dropdown properties, is there somewhere else I should be it? Is there a way to run it as an action so when I mouse up all three text fields populate?
My current script
if (event.value=="1 month")this.getField("SocialSkillsCASnapshot").value = "Snapshot of 1 month old babies in this area: Babies enjoy looking at faces and will brighten when talked to. They enjoy touch and being held by familiar adults. Babies recognize their moms by smell, touch, voice and face. They may already start to engage in vocal turn taking. Babies express feelings by cooing, gurgling and crying. They are learning how to internalize strategies for self-soothing."; else if (event.value=="2 months") this.getField("SocialSkillsCASnapshot ").value = "Snapshot of 2 month old babies in this area: Babies will now react to caregivers by smiling, vocalizing and moving their arms and legs vigorously with excitement to interact. They enjoy watching faces and are very responsive to facial expressions, movements and tone of voice. Babies enjoy touch and being held by familiar adults. Crying diminishes with eye contact from a caregiver and they maintain eye contact when socializing. Their ability to self soothe is improving. They express feelings by cooing, gurgling and crying."; else if (event.value=="3 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 3 month old babies in this area: Babies enjoy touch and being held by familiar adults. They are now regularly smiling and cooing during face-to-face interactions and have a strong attachment to primary caregivers. They will maintain eye contact as they take turns vocalizing to socialize with caregivers. They may even copy some facial expressions. Babies have special smiles just for parents/caregivers and may show signs of distress if handled by an unfamiliar adult. They express feelings by cooing, gurgling and crying."; else if (event.value=="4 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 4 month old babies in this area: Babies are very interested in socializing with familiar people using their voice. They will take turns making sounds and copy facial expressions. They now expect and elicit responses from others. They are starting to recognize unfamiliar people and places. They become excited at new and different toys. They are now showing pleasure/ displeasure by vocalizing and may even laugh. If they are crying, they will often stop when their caregivers talk to them."; else if (event.value=="5 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 5 month old babies in this area: Babies are becoming even more social. They are starting to interact with caregivers for reasons other than for comfort and security. They will more often initiate interactions by maintaining eye contact while smiling and vocalizing at parents and other familiar people. They are beginning to play along with baby games like tickles, peek-a-boo and pat-a-cake. Babies can distinguish between friendly and angry voices. They are showing pleasure and displeasure through vocalizing and they may even laugh. When crying, they will often stop if a caregiver talks to them."; else if (event.value=="6 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 6 month old babies in this area: Babies are very interested in being with people. They are now responsive to facial expressions (smiling to smiles, becoming upset to angry expressions). They will engage adults by using their voice, waving and reaching. They will turn immediately upon hearing Mom’s or Dad’s voice across the room. Babies may protest separation from primary caregivers and need time to study new people. Stranger anxiety may be present. Babies will coo, babble and smile when socializing if happy, and vocalize displeasure when unhappy. They now enjoy looking in the mirror and will smile at their image."; else if (event.value=="7 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 7 month old babies in this area: Babies are very interested in being with people. They are now responsive to facial expressions (smiling to smiles, becoming upset to angry expressions). Babies are more often engaging others socially through eye contact and gestures, (like holding their arms up to be picked up or pushing things away to protest). They will squeal, giggle and call out to get attention. Stranger anxiety may still be present, with babies clinging to mom or dad if someone unfamiliar approaches. Babies may show fleeting interest in other babies, but interactions will typically be limited to a coo or a grab."; else if (event.value=="8 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 8 month old babies in this area: Babies are very interested in being with people. They continue to increase their ability to vocalize in ‘conversation’ as they engage with their caregivers using gestures and maintaining eye contact. They start to initiate social games like peek-a-boo. Babies use gestures and vocalizations to protest as well as make requests. Babies are very attached to caregivers. First stranger anxiety may be resolving. Babies may show fleeting interest in other babies, but interactions will typically be limited to a coo or a grab."; else if (event.value=="9 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 9 month old babies in this area: Babies now look at parent’s face and expression if they need information about a new situation or person. They focus their attention more on objects that others are focused on too (joint attention). They engage parents with smiles and back and forth sound play as they maintain eye contact. Babies will repeat actions if their parents laugh at them. They will turn their head when their name is called. Babies may be starting to use social gestures to interact with others: waving, holding toys up to show others, looking back at others to ‘request’, and pushing away to protest/ refuse. Babies may show fleeting interest in other babies, but interactions will typically be limited to a coo or a grab."; else if (event.value=="10 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 10 month old babies in this area: Babies now look at parent’s face and expression if they need information about a new situation or person. They more often focus their attention on objects that others are focused on too (joint attention). They maintain eye contact when engaging in turn-taking and social games like peek-a-boo. Babies may imitate gestures, sounds or words. They are starting to respond to ‘no’ and will briefly stop. They show sensitivity to the mood of others and may cry if others are crying. Babies are using gestures and their voice to interact with others: waving, holding toys up to show others, looking back to ‘request’ and pushing away to protest/refuse. Babies may show fleeting interest in other babies, but interactions will typically be limited to a coo or a grab."; else if (event.value=="11 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 11 month old babies in this area: Babies now look at parent’s face and expression if they need information about a new situation or person. They can focus their attention on objects/activities that others are focused on too (joint attention). Babies participate in social games like peek a boo, maintaining eye contact, using gestures and their voice. They are starting to respond to ‘no’ and will briefly stop when it is heard. Showing sensitivity to others’ moods is present and they will express at least two emotions (pleasure, fear, sadness, etc.) through facial expressions and body language. Babies interact with others by waving, holding toys up to show them, looking back at others to ‘request’ and pushing away to protest. They will show interest in other babies, including coos, grabs, smiles and may even attempt to imitate another baby’s sounds."; else if (event.value=="12 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 12 month old babies in this area: Babies still enjoy sharing their focus on an object/activity with a caregiver, but they are also becoming more independent and autonomous. They will start to test limits, this helps them learn rules and consequences of breaking them. They may hand toys to mom or dad when asked. Babies will spend time watching what other babies are doing and may even imitate them. They maintain eye contact as well as use gestures and their voice to greet, request, comment and protest/refuse. They may even be saying their first words socially. They show sensitivity to the mood of others and will express at least two emotions (pleasure, fear, sadness, etc.) through facial expression and body language."; else if (event.value=="13 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 13 month old children in this area: Children enjoy sharing their focus on an object/activity with a caregiver but they are becoming more independent and autonomous. They will test limits, this helps them learn rules, and the consequences of breaking them. They also start following directions to please adults. Children are using gestures and their voice often to request, comment and protest/refuse and even respond to adult conversational attempts-even if their responses may be off topic. They will maintain eye contact as they socialize with others using babbles, jargon and a few early words. Children will spend time watching what other children are doing and may even imitate them. They will show awareness of the feelings of others, maybe even crying if someone else is sad."; else if (event.value=="14 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 14 month old children in this area: Children will show affection to mom and dad by giving them hugs and kisses. They may also hug stuffed animals or dolls. They want to be near adults and will engage in social games to please them. Children will seek out opportunities to share attention on an object or activity with caregivers (story time, etc.). They are aware of, and interested in, peers but tend to watch and imitate what they see other kids do rather than interact with them. Children will maintain eye contact as they use gestures, jargon and some words to make requests, comments, protest/refuse, and respond to what others say to them. They will show awareness of the feelings of others.”; else if (event.value=="15 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 15 month old children in this area: Children are starting to be more comfortable playing away from familiar people but will retreat to caregivers if an unfamiliar adult approaches. They maintain eye contact as they use words, gestures and some jargon to request, comment, protest/refuse and respond to what others say. They enjoy shared experiences with adults, but attention span is short. They may be hardest on the caregiver they depend on the most. They are aware of, and interested in peers, but tend to watch and imitate what they see other kids do rather than interact with them as they are still quite self-focused. Temper tantrums are emerging.”; else if (event.value=="16 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 16 month old children in this area: Children are imitating grown up activities, possibly pretending to talk on the phone or wipe down a table. They enjoy engaging with adults and doing activities to please them. When socializing, they will use gestures and words to “talk” to others while maintaining eye contact and shared affect (emotion). They communicate to make requests, comments, refusals and respond to what other say. Children may get anxious around strangers and prefer to be near caregivers. They are aware of, and interested in peers, but tend to watch and imitate what they see other kids do rather than interact with them as they are still quite self-focused."; else if (event.value=="17 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 17 month old children in this area: Children enjoy engaging with adults and doing activities to please them. They are now able to share their focus on an object/activity with a caregiver for longer periods of time. They use eye contact, gestures and some words when making requests, comments, protest/refusals, when responding to others and when expressing their feelings. They are aware of and very interested in other children. They will play near them using similar toys in similar ways. On occasion, they may compete for a toy with another child. This is a critical period where children begin to understand that people exist and there is a whole world they can interact with."; else if (event.value=="18 months") this.getField("SocialSkillsCASnapshot").value = “Snapshot of 18 month old children in this area: Children are using words more often to make requests, comments, protest/refuse, greet and respond to others while maintaining eye contact as they interact socially. Children are now often found playing near each other with similar toys. They may bite, hit, scratch or pull hair if overwhelmed and unable to express this frustration with words. Pushing limits, saying ‘no’ and tantrums are all part of children’s development at this age. They may express more complex emotions such as fear, sympathy, modesty, guilt and embarrassment through facial expression and body language more so than words. They can now predict that a broken toy will make another child unhappy. They may attempt to change the other child’s affect by offering a suitable toy. "; else if (event.value=="19 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 19-21 month old children in this area: Children frequently use their words to communicate with others as they make comments/tell info, make requests, respond to others and even attempt to initiate pretend play. They know that it’s important to look at other people as they talk to them. Children have a better understanding of others’ feelings. They will now try to comfort others if they are distressed. Increasing independence allows them to move away from parents and sit with other familiar adults. Children will exhibit varying emotions in play, they may even be seen scolding stuffed animals/dolls. They are interested in playing with other children and can play with similar toys in similar ways near their peers, but may not be able to share yet.”; else if (event.value=="20 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 19-21 month old children in this area: Children frequently use their words to communicate with others as they make comments/tell info, make requests, respond to others and even attempt to initiate pretend play. They know that it’s important to look at other people as they talk to them. Children have a better understanding of others’ feelings. They will now try to comfort others if they are distressed. Increasing independence allows them to move away from parents and sit with other familiar adults. Children will exhibit varying emotions in play, they may even be seen scolding stuffed animals/dolls. They are interested in playing with other children and can play with similar toys in similar ways near their peers, but may not be able to share yet."; else if (event.value=="21 months") this.getField("SocialSkillsCASnapshot").value = " Snapshot of 19-21 month old children in this area: Children frequently use their words to communicate with others as they make comments/tell info, make requests, respond to others and even attempt to initiate pretend play. They know that it’s important to look at other people as they talk to them. Children have a better understanding of others’ feelings. They will now try to comfort others if they are distressed. Increasing independence allows them to move away from parents and sit with other familiar adults. Children will exhibit varying emotions in play, they may even be seen scolding stuffed animals/dolls. They are interested in playing with other children and can play with similar toys in similar ways near their peers, but may not be able to share yet."; else if (event.value=="22 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 22-24 month old children in this area: Children are using many words, and possibly 2-word phrases, along with eye contact to request, comment, greet, protest, etc... They are developing a sense of self, now using ‘mine’ and are claiming everything as their own. They are interested in playing with other children and do well when playing with similar toys in similar ways near their peers, but may still have difficulty sharing toys. They will start to imitate routines that they see in everyday life in their play. Children show a wide variety of emotions, including jealousy-especially concerning family members. They now understand that others get happy when they get something and sad when they don’t. They may attempt to comfort others when they see that they are distressed."; else if (event.value=="23 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 22-24 month old children in this area: Children are using many words, and possibly 2-word phrases, along with eye contact to request, comment, greet, protest, etc... They are developing a sense of self, now using ‘mine’ and are claiming everything as their own. They are interested in playing with other children and do well when playing with similar toys in similar ways near their peers, but may still have difficulty sharing toys. They will start to imitate routines that they see in everyday life in their play. Children show a wide variety of emotions, including jealousy-especially concerning family members. They now understand that others get happy when they get something and sad when they don’t. They may attempt to comfort others when they see that they are distressed."; else if (event.value=="24 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 22-24 month old children in this area: Children are using many words, and possibly 2-word phrases, along with eye contact to request, comment, greet, protest, etc... They are developing a sense of self, now using ‘mine’ and are claiming everything as their own. They are interested in playing with other children and do well when playing with similar toys in similar ways near their peers, but may still have difficulty sharing toys. They will start to imitate routines that they see in everyday life in their play. Children show a wide variety of emotions, including jealousy-especially concerning family members. They now understand that others get happy when they get something and sad when they don’t. They may attempt to comfort others when they see that they are distressed."; else if (event.value=="25 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 25-27 month old children in this area: Children are now combining words to make requests, comments, greet others, protest/refuse, acknowledge others and respond to information said to them. They understand that looking at someone is important when you talk with them. They are developing a strong sense of independence and might become easily frustrated if they are unable to do something themselves. Children may start to express modesty, pity and shame through facial expressions and body language. Their interest in other children continues to grow and they are now able to offer toys and initiate play with others (although the play may not always be successful). They are aware of how others feel and understand that others get happy when they get something, and sad when they don’t."; else if (event.value=="26 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 25-27 month old children in this area: Children are now combining words to make requests, comments, greet others, protest/refuse, acknowledge others and respond to information said to them. They understand that looking at someone is important when you talk with them. They are developing a strong sense of independence and might become easily frustrated if they are unable to do something themselves. Children may start to express modesty, pity and shame through facial expressions and body language. Their interest in other children continues to grow and they are now able to offer toys and initiate play with others (although the play may not always be successful). They are aware of how others feel and understand that others get happy when they get something, and sad when they don’t."; else if (event.value=="27 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 25-27 month old children in this area: Children are now combining words to make requests, comments, greet others, protest/refuse, acknowledge others and respond to information said to them. They understand that looking at someone is important when you talk with them. They are developing a strong sense of independence and might become easily frustrated if they are unable to do something themselves. Children may start to express modesty, pity and shame through facial expressions and body language. Their interest in other children continues to grow and they are now able to offer toys and initiate play with others (although the play may not always be successful). They are aware of how others feel and understand that others get happy when they get something, and sad when they don’t."; else if (event.value=="28 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 28-30 month old children in this area: Children are now combining words to make requests, comments, greet others, protest/refuse, acknowledge others and respond to information said to them. They are better able to relate simple imaginative tales and will even misrepresent reality (fib, tease). They know that looking at someone is important when you talk with them. They are very interested in playing alongside peers and more often talk in short phrases as they share toys during pretend play. They will express emotions of pity, shame and modesty through their behavior and facial expressions. They understand that others get happy when they get something, and sad when they don’t."; else if (event.value=="29 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 28-30 month old children in this area: Children are now combining words to make requests, comments, greet others, protest/refuse, acknowledge others and respond to information said to them. They are better able to relate simple imaginative tales and will even misrepresent reality (fib, tease). They know that looking at someone is important when you talk with them. They are very interested in playing alongside peers and more often talk in short phrases as they share toys during pretend play. They will express emotions of pity, shame and modesty through their behavior and facial expressions. They understand that others get happy when they get something, and sad when they don’t."; else if (event.value=="30 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 28-30 month old children in this area: Children are now combining words to make requests, comments, greet others, protest/refuse, acknowledge others and respond to information said to them. They are better able to relate simple imaginative tales and will even misrepresent reality (fib, tease). They know that looking at someone is important when you talk with them. They are very interested in playing alongside peers and more often talk in short phrases as they share toys during pretend play. They will express emotions of pity, shame and modesty through their behavior and facial expressions. They understand that others get happy when they get something, and sad when they don’t."; else if (event.value=="31 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 31-33 month old children in this area: Children are now using phrases to talk about absent objects, remote events and even misrepresenting reality (teasing, fibs) in addition to communicating for more basic functions. They engage in conversation with both adults and peers. Interactive play with other children occurs frequently and they may even verbalize a play plan to others (e.g., ‘I’m mommy, you be baby’). They will express emotions like pity, shame and modesty through their behavior and facial expressions. They may use words like ‘happy’, ‘sad’, ‘mad’ or ‘scared’ to talk about how they, or others, feel. They take pride in their achievements."; else if (event.value=="32 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 31-33 month old children in this area: Children are now using phrases to talk about absent objects, remote events and even misrepresenting reality (teasing, fibs) in addition to communicating for more basic functions. They engage in conversation with both adults and peers. Interactive play with other children occurs frequently and they may even verbalize a play plan to others (e.g., ’I’m mommy, you be baby’). They will express emotions like pity, shame and modesty through their behavior and facial expressions. They may use words like ‘happy’, ‘sad’, ‘mad’ or ‘scared’ to talk about how they, or others, feel. They take pride in their achievements."; else if (event.value=="33 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 31-33 month old children in this area: Children are now using phrases to talk about absent objects, remote events and even misrepresenting reality (teasing, fibs) in addition to communicating for more basic functions. They engage in conversation with both adults and peers. Interactive play with other children occurs frequently and they may even verbalize a play plan to others (e.g., ‘I’m mommy, you be baby’). They will express emotions like pity, shame and modesty through their behavior and facial expressions. They may use words like ‘happy’, ‘sad’, ‘mad’ or ‘scared’ to talk about how they, or others, feel. They take pride in their achievements."; else if (event.value=="34 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 34-36 month old children in this area: Children now converse in sentences and attempt to control situations verbally. They respond to requests to clarify information and will continue topics by adding new information. They understand the importance of looking at people when they socialize. Words like ‘happy’, ‘sad’, ‘mad’ and ‘scared’ are used to talk about how they are feeling. Emotions may shift suddenly as they learn to handle them. Children think about the feelings of others, they may only be able to relate emotionally if they share the same perspective as the other person. They can participate in circle or interactive games with their friends. They tend to be dictatorial and demanding at this age."; else if (event.value=="35 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 34-36 month old children in this area: Children now converse in sentences and attempt to control situations verbally. They respond to requests to clarify information and will continue topics by adding new information. They understand the importance of looking at people when they socialize. Words like ‘happy’, ‘sad’, ‘mad’ and ‘scared’ are used to talk about how they are feeling. Emotions may shift suddenly as they learn to handle them. Children think about the feelings of others, they may only be able to relate emotionally if they share the same perspective as the other person. They can participate in circle or interactive games with their friends. They tend to be dictatorial and demanding at this age."; else if (event.value=="36 months") this.getField("SocialSkillsCASnapshot").value = "Snapshot of 34-36 month old children in this area: Children now converse in sentences and attempt to control situations verbally. They respond to requests to clarify information and will continue topics by adding new information. They understand the importance of looking at people when they socialize. Words like ‘happy’, ‘sad’, ‘mad’ and ‘scared’ are used to talk about how they are feeling. Emotions may shift suddenly as they learn to handle them. Children think about the feelings of others, they may only be able to relate emotionally if they share the same perspective as the other person. They can participate in circle or interactive games with their friends. They tend to be dictatorial and demanding at this age."; // else this.getField("SocialSkillsCASnapshot").value = "";
Copy link to clipboard
Copied
Adding "//" is not how you solve it. It's just causing the entire code to be ignored.
You need to start debugging it. Remove each section of the code until the problem stops, then go back to the last part you removed and look for the issue. I recommend using a plain-text editor with code highlighting features, like Notepad++. It will make your job much easier.
Using it as the custom validation script is fine.
Copy link to clipboard
Copied
Use line breaks in your code.
Copy link to clipboard
Copied
Good point. That will give a much better indication of where the error actually happens, as it won't all be a single line of code.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more