Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

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
Level 5

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

0 Replies

Avatar

Correct answer by
Level 5

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

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