# Buttons and fields

Hi all,
I am very new to CL, but have some experience programming in other languages. I’m trying to figure out how to make a button interact with a field:

What I want this to do is for the user to input a number and then be able to click the buttons to change that number repeatedly. When they click the times 3, plus 1 button, it would replace the old number. I really have no idea how to make this work and am a bit lost in the documentation. I tried a few things, like this:

Thanks for any advice you can give me!

Working from a mobile device right now, but I think this should work:

``````num = numericValue("\${mynum}*3+1")
``````

You won’t be able to change what shows in the input. You could have a note show it (and simultaneously hide the input until you’re ready for another.

Oh! How do I do that?

@Nate_Moore
I took what you had outlined and ran with it.
The early move is a copy of the student input to a note, and I hide the student input.
I have the buttons disabled until the previous one is pushed (assuming you wanted to keep continuing through more operations).

Order of Operations - student input; teacher steps â¢ Activity Builder by Desmos

I think I’m starting to see how to make this work. The issue I’m having is that I need to be able to use each button more than once. The way the Collatz conjecture works is that students take a number and follow these rules:

If the number is even, divide by 2
If the number is odd, multiply by 3 and add 1

The conjecture is that all numbers will eventually get to 1, so I’m trying to build something that lets students test this out easily in Desmos. Thanks for your help so far!

You’re gonna need to use capture in some way to move from value to value. There are a bunch of ways, here’s one. Would LOVE to see some other methods from folks here.

2 Likes