ColdFusion select option 用法,看看哪种适合你的

阅读更多

 

1.

Function setSelected(val1, val2){
    if (val1 EQ val2)
    {
        Return 'selected="selected"';
    } 
    else 
    {
        Return '';
    }
}

id="grade"name="grade">
  value="A" #setSelected('A', form.grade)#>A
  value="B" #setSelected('B', form.grade)#>B 
  value="C" #setSelected('C', form.grade)#>C 
  value="D" #setSelected('D', form.grade)#>D 
  value="F" #setSelected('F', form.grade)#>F



2.
id="grade"name="grade">
  
   
   
   
  

3.
name="getGrades"datasource="#application.dsn#">
  select gradeLetter from Grades



  name="grade"
  query="getGrades"
  display="gradeLetter"
  value="gradeLetter"
  selected="#form.grade#"/>
4.
name="form.grade"default="C">
mydata=[{grade="A",value="A"},{grade="B",value="B"},{grade="C",value="C"},{grade="D",value="D"},{grade="F",value="F"}]>

id="grade"name="grade">
    array="#mydata#"index="i">
        
    


5.
variable="GradeOptions">
A:A
B:B
C:C
D:D
F:F


id="grade"name="grade">
    index="CurOpt"list="#trim(GradeOptions)#"delimiters="#Chr(10)#">
        
    

6.
variable="GradeOptions">
A
B
C
D
F


id="grade"name="grade">
    index="CurOpt"list="#trim(GradeOptions)#"delimiters="#Chr(10)#">
        form.gradeEQCurOpt> selected="selected">#CurOpt#
    

7.
name="form.grade"default="A">

id="grade"name="grade">
index="code"from="65"to="90">
    



8.
GradeOptions=Grades.readAvailable()/>

id="grade"name="grade">
    query="GradeOptions">
        
    
9.
id="grade"name="grade">
      
       
       
       
      
   
10.
type="text/javascript">                                         
  jQuery(document).ready(function(){
     $("#grade option[value='#FORM.Grade#']")
      .attr('selected','selected');
  });


id="grade"name="grade">
  value="A">A
  value="B">B 
  value="C">C 
  value="D">D 
  value="F">F

你可能感兴趣的:(coldfusion)