简体   繁体   English

选择的单选按钮使字段为真或假

[英]Selected radio button make field true or false

I have the following code: 我有以下代码:

    <?php $radioSwitch = of_get_option('radio_switch');
                                if ($radioSwitch == "true") { ?>
                                    <!-- radio switch -->
                                    <div class="row switches clearfix">
                                        <input type="radio" name="switch" id="switch1" value="<?php echo of_get_option('switch1'); ?>" /><label for="switch1" class="field"><?php echo of_get_option('switch1'); ?></label>
                                        <input type="radio" name="switch" id="switch2" value="<?php echo of_get_option('switch2'); ?>" /><label for="switch2" class="field"><?php echo of_get_option('switch2'); ?></label>
                                    </div>
                                <?php } ?>

................................................................................


    <?php
                            $datePicker1 = of_get_option('datepicker1');
                            $datePicker2 = of_get_option('datepicker2');
                            if (($datePicker1 == "true") || ($datePicker2 == "true")) { ?>
                                <div class="row clearfix">
                                <?php if ($datePicker1 == "true") { ?>

                                    <!-- datepicker 1 -->
                                    <input type="text" id="dateFrom" name="<?php echo of_get_option('datepicker1_text'); ?>" value="<?php echo of_get_option('datepicker1_text'); ?>" tabindex="6" />
                                    <label class="error" for="dateFrom" id="dateFrom_error">Selectați data.</label>
                                <?php } ?>                  

                            <?php if ($datePicker2 == "true") { ?>

                                    <!-- datepicker 2 -->
                                    <input type="textarea" id="dateTo" name="<?php echo of_get_option('datepicker2_text'); ?>" value="<?php echo of_get_option('datepicker2_text'); ?>"  tabindex="7" />
                                    <label class="error" for="dateTo" id="dateTo_error">Selectați data.</label>
                                <?php } ?>
                                </div>
                            <?php } ?>

If radio button "switch1" is selected, only "$datepicker1" must be true and "$datepicker2" must be false, and if radio button "switch2" is selected, both "$datepicker1" and "$datepicker2" must be true. 如果选择了单选按钮“ switch1”,则仅“ $ datepicker1”必须为真,而“ $ datepicker2”必须为false,并且如果选择了单选按钮“ switch2”,则“ $ datepicker1”和“ $ datepicker2”都必须为真。 Anyone could help me? 有人可以帮助我吗?

PHP is a server-side language which is parsed on the server . PHP是在服务器上解析的服务器端语言。 You cannot modify variables of PHP on the browser. 您不能在浏览器上修改PHP的变量。

Try submitting the radio button options as a form into a PHP page. 尝试将单选按钮选项作为表单提交到PHP页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM