代码之家  ›  专栏  ›  技术社区  ›  flash

如何在单选按钮中集成php代码?

  •  0
  • flash  · 技术社区  · 5 年前

    fiddle 对于我在代码库中使用的单选按钮。

    开/关

    <td valign="top">
       <fieldset style="background-color:#EDADFF;">
          <legend><strong>Homepage Tiles</strong></legend>
          <input type="radio" id="toggle-on" value="3" name="toggle_status" <?php if($data->{"toggle_status"}==3){echo
             'checked';}?>/>
          <label for="toggle-on">On</label>
          <input type="radio" id="toggle-off" value="0" name="toggle_status" <?php if($data->{"toggle_status"}==0){echo
             'checked';}?> />
          <label for="toggle-off">Off</label>
       </fieldset>
    </td>
    


    我想知道 如果($data->{“切换状态”}==3) (表示当切换为

    我想集成的php代码片段 是:

    <?php
    $special_reports = new \WP_Query( [
        'post_type' => 'current-special-report',
        'orderby'   => 'menu_order',
        'order'     => 'ASC',
        'posts_per_page' => 2,
    ]);
    switch(ICL_LANGUAGE_CODE){
        case 'en':
            $url = "http://www.current.ca/en/current-in-focus/";
            $url_ess = "http://www.current.ca/en/programs/lessentiel-with-esther-begin/";
            $url_ptp = "http://www.current.ca/en/programs/primetime-politics/";
            $url_out = "http://www.current.ca/en/programs/outburst/";
            $url_per = "http://www.current.ca/en/programs/perspective-with-alison-smith/";
            $link_view = "View All";
            break;
        case 'fr':
            $url = "http://www.current.ca/fr/dossiers-current/";
            $url_ess = "http://www.current.ca/fr/programs/lessentiel-avec-esther-begin/";
            $url_ptp = "http://www.current.ca/fr/programs/lheure-politique/";
            $url_out = "http://www.current.ca/fr/programs/outburst/";
            $url_per = "http://www.current.ca/fr/programs/perspective-avec-alison-smith/";
            $link_view = "Toutes";
            break;
    }
    
    
    $horizontal_class = ( get_query_var( 'current_in_depth_full', false ) ) ? '-horizontal': '';
    
    // Mon-Thur Essentiel/PTP
    // Fri-Sun Persp/Outburst
    $arradate = strtolower(date('D'));
    date_default_timezone_set('America/Toronto');
    $nowtime = date('H:i:s');
    $tue_thu = array('tue','wed','thu');
    ?>
    
    0 回复  |  直到 5 年前
        1
  •  0
  •   Tuckbros    5 年前

    我不知道这一点。PHP主要是一种服务器端语言,可以帮助动态构建内容。 当服务器将交付页面时,php将测试您的$data并相应地检查radiobutton。 如果您希望php根据toogle对页面进行任何更改,则必须将其提交给php(即服务器),以便服务器知道用户的选择并提供更新的页面。 否则你必须使用客户端语言(javascript或我不知道还有什么)