views:

348

answers:

4

Hi all, 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&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>

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

A: 

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.

GSto
i think is ok even it refreshing the page, thank you
jones
+1  A: 

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>
Mikuso
Thank You Mikuso, Maybe like this,..if($lang_select == 'de') $languages = array( 'Pages' => 'Seiten', 'Bla..' => 'Bla..', ); //endarray} elseif ($lang_select == 'fr'){ $languages = array ( 'Pages' => '???', 'Bla..' => 'Bla..',} else{ $languages = array ( 'Pages' => 'Pages', 'Bla..' => 'Bla..',} ;
jones
A: 

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..

jones
A: 

Hi I want to select drop down by selecting radio button.The value will be shown in the drop down menu as per radio button. Then I want to link the selected item to the page related to the selected options.can it be possible by using php or javascript? pls send me some suggesion ...

Abhijit