Answer the question
In order to leave comments, you need to log in
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 } ?>
echo $option['name'];
Answer the question
In order to leave comments, you need to log in
switch ($option['name']) {
case "Выберите размер":
echo "Размер";
break;
case 1:
echo "i равно 1";
break;
case 2:
echo "i равно 2";
break;
default:
echo $option['name'];
}
In the most primitive version:
if($_POST['data']==="Выбрать размер") $_POST['data']= "Размер";
In <?php echo $option['name']; ?> is set to "Choose Size".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question