How can I pass Streamlit variable saco to javascript
saco ="test"
html_string = '''
<div id="res" ></div>
<script language="javascript">
let str = = '{{saco}}';
document.querySelector("#res").innerHTML = str;
alert(str)
</script>
'''
components.html(html_string)
ferdy
2
Use the f-string properly and correct assignment operator.
saco = "test"
html_string = f'''
<div id=res></div>
<script type="text/javascript">
let mystr = "{saco}";
document.querySelector("#res").innerHTML = mystr;
alert(mystr)
</script>
'''
components.html(html_string)
1 Like
system
Closed
4
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.