flexx
flexx copied to clipboard
how to send data from dropdown in js back to python
i am creating a GUI using python EEL
In this UI i have a drop down . user will select the value of dropdown and submit and that dropdown value will reflect in python console.
but i am unable to receive value from javascript
this is my python code:
from random import randint
import eel
eel.init("web")
# Exposing the random_python function to javascript
@eel.expose
def random_python():
print("Random function running")
return randint(1,100)
@eel.expose
def getList():
lst = ["a","b","c","d"]
return lst
eel.spawn(eel.js_myval()())
eel.start("index.html")
this is my javascript:
let lst =document.getElementById("cate")
document.getElementById("submit").addEventListener("click",()=>{
eel.expose(js_myval)// here i am using eel expose
function js_myval(){
return lst.value;
}
})
this is my html:
<select name="meesho_category" id="cate">
<option value="x">x</option>
<option value="x">a</option>
<option value="x">b</option>
</select>
I am not sure how this question relates to Flexx. It looks like your code is only Eel and vanilla js/html. I am not familiar with Eel.