flexx icon indicating copy to clipboard operation
flexx copied to clipboard

how to send data from dropdown in js back to python

Open princebhatia09 opened this issue 3 years ago • 1 comments

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>

princebhatia09 avatar Jul 07 '21 18:07 princebhatia09

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.

almarklein avatar Jul 12 '21 07:07 almarklein