V
V
Vladislav Radzimovsky2014-07-29 17:38:52
PHP
Vladislav Radzimovsky, 2014-07-29 17:38:52

How to implement a program change using the interface?

Hello, I'm interested in this question:
Let's say we have some block of code:

If(var){
do this;
}

And at the same time, there is an interface with one radio button that disables / enables this block.
So, how to properly implement such enabling/disabling of a working block of code?
Make this block a condition as in the example and check it using some global variable, which the radio button will change? Or directly parse some config and change the value by overwriting the file itself? Or do everything through the database?
Maybe for someone the question is simple or awkward, but I don’t know how to correctly implement this functionality. Thanks in advance for your replies.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Yeletsky, 2014-07-29
@Lafafm

1. The specific implementation depends on the project, the subject area, what the code does when it is executed, and other things.
2. The variable does not have to be global.
3. I advise you to read about MVC , though I'm not sure that in this case it is needed.
Using his psychic abilities, he came to the conclusion that after all, through the base.

S
Sergey, 2014-07-29
Protko @Fesor

I understand that the question is about UI changes on the client, because otherwise I think there would be no questions.
There is such a pattern as MVVM. it is implemented by a bunch of frameworks ala Knockout.js, Angular.JS, etc. These frameworks allow you to build complex UIs using a declarative approach and data binding. That is, you will have an instant UI reaction to a change in some data or the state of the model.
In fact, you can implement something simpler for a specific task, but in any case, everything that happens on the client is written in JS.

K
Kirill_0x7C4, 2014-08-22
@Kirill_0x7C4

How do you track the state of the radio button?
Let's say, depending on the state, the radiobutton_state variable changes, switching between ENABLED and DISABLED values.
Then in code you can write:

If ((var) && ( radiobutton_state == ENABLED){
do this;
}

That is, the "do this" code will be executed only if both conditions are met: both var == TRUE and radiobutton_state == ENABLED.
Did I understand correctly what is required?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question