定义,单选按钮更改为带循环自动下拉

发布于 2024-08-17 09:07:17 字数 994 浏览 3 评论 0原文

我正在寻求帮助...并希望您好意

我想使用循环将我的网站语言模型从单选按钮更改为自动下拉按钮

这是语言

if ($lang=="en") {
//Pages
define ("Pages", "Pages") ;

}

if ($lang=="de") {
define ("Pages", "Seiten") ;
}

这是现有的单选按钮

                <td width="60%">Languange<b><BR />
                <?php 
                    if ($lang == 'en') {
                        print '<input type="radio" value="de" checked name="lang_" /> German&nbsp;&nbsp
                                <input type="radio" value="en" name="lang_" />English&nbsp';
                    }
                    else {
                        print '<input type="radio" value="de" name="lang_" />German&nbsp;&nbsp
                                <input type="radio" value="en" checked name="lang_" />English&nbsp';
                    }
                ?>
                </b></td>

和上面的单选按钮我想更改下拉按钮,我需要你的帮助

i looking for help... and hope of you kindly

I want to change my site language model from radio button to auto dropdown button using loop

This the languages

if ($lang=="en") {
//Pages
define ("Pages", "Pages") ;

}

if ($lang=="de") {
define ("Pages", "Seiten") ;
}

This the existing Radio button

                <td width="60%">Languange<b><BR />
                <?php 
                    if ($lang == 'en') {
                        print '<input type="radio" value="de" checked name="lang_" /> German  
                                <input type="radio" value="en" name="lang_" />English ';
                    }
                    else {
                        print '<input type="radio" value="de" name="lang_" />German  
                                <input type="radio" value="en" checked name="lang_" />English ';
                    }
                ?>
                </b></td>

and the Radio button above i want to change drop down button, i looking your help please

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你是年少的欢喜 2024-08-24 09:07:17

我很难理解你的问题,但你想做这样的事情吗? (我还没有测试过这段代码)

<td width="60%">Languange<br />
    <select name="lang_">
    <?php
        $languages = array(
            'en'    =>  'English',
            'de'    =>  'German',
            'fr'    =>  'French',
        );

        foreach ($languages as $abrv => $language) {
            printf(
                '<option %s value="%s">%s</option>',
                $lang == $language ? 'selected' : '',
                htmlentities($abrv),
                htmlentities($language)
            );
        }
    ?>
    </select>
</td>

I am struggling to understand your question, but are you looking to do something like this? (I haven't tested this code yet)

<td width="60%">Languange<br />
    <select name="lang_">
    <?php
        $languages = array(
            'en'    =>  'English',
            'de'    =>  'German',
            'fr'    =>  'French',
        );

        foreach ($languages as $abrv => $language) {
            printf(
                '<option %s value="%s">%s</option>',
                $lang == $language ? 'selected' : '',
                htmlentities($abrv),
                htmlentities($language)
            );
        }
    ?>
    </select>
</td>
唯憾梦倾城 2024-08-24 09:07:17

在 PHP 中,如果不刷新页面就无法执行此操作。否则,您可以使用 JavaScript 来检测单选按钮何时被单击,然后相应地更改下拉列表。

you can't do this in PHP without refreshing the page. otherwise, you can use JavaScript to detect when the radio buttons are clicked, and then change the drop down appropriately.

纸短情长 2024-08-24 09:07:17

我曾经见过这样的代码,我想要,

function optionbox($boxname, $cssclass, $elementsarray, $cat_activ=1) {
    echo "<select name='$boxname' class='$cssclass'>";
    while (list($key,$value) = each($elementsarray)) {
        if ($key == $cat_activ) {               // Kategory ist actif 
            $SELECTED = "SELECTED";
        } else {
            $SELECTED = "";
        } //endif
        echo "<option $SELECTED value='$key'>$value</option>";
    } //endwhile
    echo "</select>";
} 

但我是 php 新手。

I ever seen like this code, that i want to

function optionbox($boxname, $cssclass, $elementsarray, $cat_activ=1) {
    echo "<select name='$boxname' class='$cssclass'>";
    while (list($key,$value) = each($elementsarray)) {
        if ($key == $cat_activ) {               // Kategory ist actif 
            $SELECTED = "SELECTED";
        } else {
            $SELECTED = "";
        } //endif
        echo "<option $SELECTED value='$key'>$value</option>";
    } //endwhile
    echo "</select>";
} 

but i am new to php..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文