E
E
Eugene Simon2017-09-11 14:08:46
PHP
Eugene Simon, 2017-09-11 14:08:46

How to change the field value depending on the input value?

Friends, help with advice ..
The essence of the task: to receive incoming data and change to others. For example:
If we get "Select size", then we need to change to "Size".
If we get "Select color", then we need to change it to "Color".
And now in detail. I'm working on a shopping cart in opencart. There, the selected option is attached to the selected product, for example: Select size - 43. The source code is as follows:

<?php foreach ($product['option'] as $option) { ?>
    <?php echo $option['name']; ?>: - <?php echo $option['value']; ?>
<?php } ?>

The value is "Choose Size". And there are many such options. <?php echo $option['name']; ?>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Z
zoozag, 2017-09-12
@Comers

switch ($option['name']) {
    case "Выберите размер":
        echo "Размер";
        break;
    case 1:
        echo "i равно 1";
        break;
    case 2:
        echo "i равно 2";
        break;
    default:
       echo $option['name'];
}

P
Pavel Kornilov, 2017-09-11
@KorniloFF

In the most primitive version:

if($_POST['data']==="Выбрать размер") $_POST['data']= "Размер";

T
ThunderCat, 2017-09-11
@ThunderCat

In <?php echo $option['name']; ?> is set to "Choose Size".

ok, where should i replace it? what is the principle of replacement? a list in the database, just written out on a piece of paper, an array, is there anything to replace with?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question