dongnaigu2052 2015-06-22 18:27
浏览 75

如何根据选择的字段显示按钮?PHP

I have this site.

At the bottom you will find some products ... four of them have the word "buton1" or "buton2"

The site is made with this Wordpress plugin and custom fields.

Basically I have two radio buttons.

I want to put my button, depending on which item is selected, in the admin panel.

To do this, I tried the following code:

CODE PHP:

<p class="test">   <?php

$variable = get_field('button');
echo $variable;
if(buton1 is selected)
{
 <a href="?page_id=26" class="get_quote">get quote</a> //display the button
}else if(buton2 is selected){
 //hide the button 
}
?>

You can help me please tell me what I should do to fill my code?

How can I verify that the button is selected?

Thanks in advance!

  • 写回答

1条回答 默认 最新

  • doupoji3856 2015-06-22 18:56
    关注

    when a form is submitted, all the elements in the form are posted to the submitted page with name and values, in get or post scope. depending on the form type.

    You can get the selected button as follows in php:

    $button_value = get_field('button_name');
    echo $button_value;
    
    if($button_value == 1)
    {
         <a href="?page_id=26" class="get_quote">get quote</a> //display the button
    }
    else if($button_value == 2){
         //hide the button 
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题