1
deka87
Script editing help needed
  • 2009/4/7 16:32

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


HI, guys. I need help on this:

//Source language    
        /* $select = new XoopsFormSelect("Source language",'lang1',$editform->lang1_);
        for($i=1;$i<=5;$i++)
            $select->addOption($i,$i);

        $form->addElement($select); */
        
$select_lang1 "n" ;
        for( 
$i $i <= $i ++ ) {
            
$selected $i == $question->getVar('lang1') ? "selected='selected'" "" ;
            
$select_lang1 .= "$i$selected>$in" ;
        }
        
$select_lang1 .= "n" ;


As you can see it would show a dropdown box in the form with "i" items named from 1 to 5. What I need is a dropdown with this options:

$select_lang1->addOption("Abkhazian");
    
$select_lang1->addOption("Afar");
    
$select_lang1->addOption("Afrikaans");
    
$select_lang1->addOption("Albanian");


so that I'd add this: <{$select_lang1}> in the form template to get it shown.

Thanks!
Mind anchors

2
ghia
Re: Script editing help needed
  • 2009/4/7 19:39

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Try with:
$countries = array('Abkhazian','Afar','Afrikaans','Albanian');
        
$select_lang1 "n" ;
        for( 
$i $i $i ++ ) {
            
$selected $i == $question->getVar('lang1') ? "selected='selected'" "" ;
            
$select_lang1 .= "$i$selected>$countries[$i]n" ;
        }
        
$select_lang1 .= "n" ;

Login

Who's Online

446 user(s) are online (310 user(s) are browsing Support Forums)


Members: 0


Guests: 446


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits