开发者

How to add textfields dynamically and add information in to database?

开发者 https://www.devze.com 2023-02-13 17:59 出处:网络
I have a form that I want to keep adding textfields to and then add the information to an entity in my database. I have the model configured yet can\'t think of the best approach to keep adding textfi

I have a form that I want to keep adding textfields to and then add the information to an entity in my database. I have the model configured yet can't think of the best approach to keep adding textfields and getting django to read them as the form will have other fields in it. So basically i have a form that has some fields and then once details are entered in to one of the fields it displays another. I am now stuck on how to pass the information to my applicat开发者_高级运维ion should i pass an array of numbers which is the length of the fields that have been used, then iterate through the array obtaining the information from the fields or is there a better approach?


If the number of text fields is arbitrary, you could add a new textfield via JavaScript when the last one is filled out and submit the value of the textfield via ajax. You might want to check out the JavaScript library, jquery.

If you could add more specifics to the question I could be of more help.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号