Hi everybody,
I am using Anvil a lot in these days and every time I was in trouble, I found solutions just by looking in the forum.
Unfortunately, this time I cannot find the answer, so here I am: my first question.
I am building an app, and one form of it would be a custom HTML form. I want to dynamically change this form’s HTML, through Python code.
My idea is that I generate each time an image in Python, with the related HTML code, and then I will update this custom HTML on the anvil form, displaying that image.
I have tried something: if I edit the Custom HTML form and I upload the image in assets, everything works… but static, for one image and one HTML, without the possibility of changing them.
perhaps it depends to the fact that I am not so HTML skilled…
Hence, is it possible to do so in Anvil? Or is there a better way to achieve the same goal?
Thank you very much for the help!
Daniele
Have you tried using the image or canvas components Anvil has? That apuld probably be easiest
1 Like
You can easily change the HTML of a form.
self.html='<b> This form has been changed </b>'
Alternatively, components like Richtext or HtmlTemplate can help you achieve that.
1 Like
Thank you very much for the reply!
The Iframe component was the answer to all my problems!
1 Like
I looked through this thread, but I haven’t found a good solution to modifying the HTML of a Custom HTML form with code.
I tried self.html
but my form was not modified, and I think an iFrame is not what I am looking for.
Is importing and using a library like BeautifulSoup the best solution for only modifying certain elements of a Custom HTML file programmatically?
https://www.crummy.com/software/BeautifulSoup/bs4/doc/
You should probably post a new topic with your specific question, with more details, since the original poster had their question answered.
I can guarantee that assigning to self.html
in a custom HTML form will change the HTML displayed for that form, so providing the code that isn’t working will help people to help you.
1 Like