Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Newbie help needed. Looking to circle options on a form.

Avatar

Level 2

Hey Guys,

I'm a total beginner at this, but we've been mapping out forms and I need to know how to be able to "circle" different options on a form.

I think the best way to do this is to have a button which makes a circle object visible or hidden.  Currently I've figured out how to set an object as hidden and make it appear on button click, but not make it go back to hidden if the button is clicked again.  Many times its just a yes/no type case, but sometimes there are cases where I have multiple options where only one can be selected and I would like to be able to click and circle the appropriate type.

An example:

How many cylinders does your vehicle have:

     4     6     8

and I would like to make it so if you click the 4 it will circle the 4 and make sure the 6 and 8 are not circled.

Any help would be appreciated.

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

You can use a control variable to make this button a toggle.

For instance, use a variable like circleVisible = 0 and make circleVisible = 1 when the button is clicked and the circle is visible.

So you would have something like this, when button is clicked:

if (cicleVisible == 0) {

   <make circle visible>

   circleVisible = 1

} else {

  <make circle invisible>

   circleVisible = 0

}

Got it?  :)

View solution in original post

3 Replies

Avatar

Correct answer by
Former Community Member

You can use a control variable to make this button a toggle.

For instance, use a variable like circleVisible = 0 and make circleVisible = 1 when the button is clicked and the circle is visible.

So you would have something like this, when button is clicked:

if (cicleVisible == 0) {

   <make circle visible>

   circleVisible = 1

} else {

  <make circle invisible>

   circleVisible = 0

}

Got it?  :)

Avatar

Level 2

Thanks a lot!

That works great.

Avatar

Level 2

How about this case:

There are three different cases that could be true, 4 cylinders, 6 cylinders and 8 cylinders.  I have created the 4, 6 and 8 as buttons, and created three circle objects as cyl4, cyl6 and cyl8.  I want it so that when 4 is clicked it displays the circle object cyl4 and makes the others hidden, unless cyl4 is already visible then it will just make all three objects hidden.  So far I have this code on each button click, modified for which objects should be set to visible on each one:

topmostSubform.Page1.Span[41].Fourcyl::click - (JavaScript, client)
if (cylinder == 4){
    xfa.form.topmostSubform.Page1.cyl4.presence="hidden"
    xfa.form.topmostSubform.Page1.cyl6.presence="hidden"
    xfa.form.topmostSubform.Page1.cyl8.presence="hidden"
    cylinder.value = 0
}
else{
    xfa.form.topmostSubform.Page1.cyl4.presence="visible"
    xfa.form.topmostSubform.Page1.cyl6.presence="hidden"
    xfa.form.topmostSubform.Page1.cyl8.presence="hidden"
    cylinder.value = 4
}

Where cylinder is just a control variable.  It's probably something simple that I'm missing, any help would be appreciated.

Thanks

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----