How can I dynamically add input fields to a form?

前端 未结 5 796
南旧
南旧 2021-01-05 17:02

I\'m not much of a web programmer, but I\'m creating a simple web app that has a form where the user can enter a series of points (x,y,z) but I don\'t know how many the user

5条回答
  •  有刺的猬
    2021-01-05 17:49

    What you're saying is that you're hand writing the input tags? Or are you saying that you want a dynamic action where a user clicks a button and it adds more table rows?

    In anycase, for your code, you just need a loop, like so. I assume $data is whatever data you want to set based on an array that is probably from the database or something:

    
      
       
       
       
       
      
    
    

    Of course you can't copy and past the above, but that's a good starting point.

    For dynamically doing it, you can't use php. What it sounds like you want to use is javascript ajax, and php combination.

提交回复
热议问题