Is it possible to use a for loop in <select> in html? and how?

后端 未结 6 1560
不知归路
不知归路 2021-01-05 20:38

I am trying to use a for loop in html but i dont even know if this is possible. Is it? and if yes how? I dont want to use php. only html and javascript.

this is my

6条回答
  •  我在风中等你
    2021-01-05 21:03

    May be you can play with javascript and innerHTML. Try this

    HTML

    
    
    

    Javascript

    function selectFunction(){  
        var x=0;   
        for(x=0;x<5;x++){
        var option = ""
        document.getElementById('selectId').innerHTML += option;   
        } 
    }   
    

提交回复
热议问题