Autofill formtext when toggle =yes

I want to automatically insert a value into a text field when a toggle is yes. This is what I currently have:

Data - {formtext: name=data; default=10}/10 {formtoggle: name=Miss; default=no}
-- You are missing the data.{endformtoggle}

I want {=data} to be 0 when formtoggle {=Miss} is yes.

I thought I could do an if statement, but it didn't change.

Hi Christiana,

Welcome to the community :tada:

How's this snippet?

Data - {if: miss=No}{formtext: default=10; cols=5; name=data}{else}{formtext: name=data\ ; default=0; cols=5}{endif}/10 {formtoggle: name=Miss; default=no}
-- You are missing the data.{endformtoggle}

That's it! Thank you!

1 Like

That worked, but now the value for data is not inserting in the formula I have elsewhere that adds data to the value for the other text fields.

Can you share the snippet here?

I think the issue is with form names in the snippet. I'll be happy to fix it for you :slight_smile:

{formtext: name=name},

{if: {=prelab+Hypo+Variables+data + analysis}< 26}I'd love to see you revise this assignment. I am here to help so if you need to, please setup a zoom/help call with me
Alternately, we offer a Live Lesson for 5.02. Check the course home page for the time it's being offered this week.{elseif: {=prelab+Hypo+Variables+data + analysis}< 32} This was tough, but that just means there is more that you can learn :slight_smile: Review the lesson a bit and let's try one more time! I can't wait to see your improvements!
Alternately, we offer a Live Lesson for 5.02. Check the course home page for the time it's being offered this week.{elseif: {=prelab+Hypo+Variables+data + analysis}< 41}Your effort showed how well you bonded with the information and identified the knowledge you needed! {else}Keep up the great work!{endif}

Pre-Lab - {formtext: name=prelab; default=10} /10

Hypothesis - {formtext: name=Hypo; default=4} /4

Variables - {formtext: name=Variables; default=6} /6

Data - {if: miss=no}{formtext: name=data; default=10}{else}{{formtext: name=data;default=0}{endif} /10 {=Variables}{formtoggle: name=Miss; default=no}
You are missing the data.{endformtoggle} {formtoggle: name=revise4; default=no}
The data you provided does not match the data from the experiment. {formtext: name=why4}{endformtoggle}

Analysis - {formtext: name=analysis; default=10} /10

TOTAL = {=prelab+Hypo+Variables+data + analysis} / 40

It is grading feed back for an assignment. I cut out all of the other feedback so this is an abbreviated version. The formatting didn't copy over so it looks messy, but I have it bullet points

How's this? I had to change the name of one of the text fields within the if statement and then add an if statement for the formula, but it should be working now.

{formtext: name=name},

{if: {=prelab+Hypo+Variables+data + analysis}< 26}I'd love to see you revise this assignment. I am here to help so if you need to, please setup a zoom/help call with me
Alternately, we offer a Live Lesson for 5.02. Check the course home page for the time it's being offered this week.{elseif: {=prelab+Hypo+Variables+data + analysis}< 32} This was tough, but that just means there is more that you can learn Review the lesson a bit and let's try one more time! I can't wait to see your improvements!
Alternately, we offer a Live Lesson for 5.02. Check the course home page for the time it's being offered this week.{elseif: {=prelab+Hypo+Variables+data + analysis}< 41}Your effort showed how well you bonded with the information and identified the knowledge you needed! {else}Keep up the great work!{endif}

Pre-Lab - {formtext: name=prelab; default=10} /10

Hypothesis - {formtext: name=Hypo; default=4} /4

Variables - {formtext: name=Variables; default=6} /6

Data - {if: miss=No}{formtext: default=10; cols=5; name=data}{else}{formtext: name=data 2; default=0; cols=5}{endif}/10 {formtoggle: name=Miss; default=no}
-- You are missing the data.{endformtoggle} {formtoggle: name=revise4; default=no}
The data you provided does not match the data from the experiment. {formtext: name=why4}{endformtoggle}

Analysis - {formtext: name=analysis; default=10} /10

TOTAL = {if: miss=No}{=prelab+Hypo+Variables+data + analysis}{else}{=prelab+Hypo+Variables+`data 2` + analysis}{endif} / 40

1 Like

That works for the total points! Now how would I change the if statements at the top to match the total?

Sorry about that, I should have fixed that in the previous version.

I changed some things, so there are more if statements, but it should work properly :slight_smile:

{formtext: name=name},

{if: miss=No}{if: total< 26}I'd love to see you revise this assignment. I am here to help so if you need to, please setup a zoom/help call with me
Alternately, we offer a Live Lesson for 5.02. Check the course home page for the time it's being offered this week.{elseif: total< 32} This was tough, but that just means there is more that you can learn Review the lesson a bit and let's try one more time! I can't wait to see your improvements!
Alternately, we offer a Live Lesson for 5.02. Check the course home page for the time it's being offered this week.{elseif: total< 41}Your effort showed how well you bonded with the information and identified the knowledge you needed! {else}Keep up the great work!{endif}
{else: trim=yes}{if: total2< 26}I'd love to see you revise this assignment. I am here to help so if you need to, please setup a zoom/help call with me
Alternately, we offer a Live Lesson for 5.02. Check the course home page for the time it's being offered this week.{elseif: total2< 32} This was tough, but that just means there is more that you can learn Review the lesson a bit and let's try one more time! I can't wait to see your improvements!
Alternately, we offer a Live Lesson for 5.02. Check the course home page for the time it's being offered this week.{elseif: total2< 41}Your effort showed how well you bonded with the information and identified the knowledge you needed! {else}Keep up the great work!{endif}{endif}

Pre-Lab - {formtext: name=prelab; default=10} /10

Hypothesis - {formtext: name=Hypo; default=4} /4

Variables - {formtext: name=Variables; default=6} /6

Data - {if: miss=No}{formtext: default=10; cols=5; name=data}{else}{formtext: name=data 2; default=0; cols=5}{endif}/10 {formtoggle: name=Miss; default=no}
-- You are missing the data.{endformtoggle} {formtoggle: name=revise4; default=no}
The data you provided does not match the data from the experiment. {formtext: name=why4}{endformtoggle}

Analysis - {formtext: name=analysis; default=10} /10

TOTAL = {if: miss=No}{total=prelab+Hypo+Variables+data + analysis}{=total}{else}{total2=prelab+Hypo+Variables+`data 2` + analysis}{=total2}{endif} / 40