# Assining JS function to HTML button

**URL:** https://community.plotly.com/t/assining-js-function-to-html-button/5271
**Category:** Dash Python
**Created:** [August 7, 2017, 7:17pm UTC](https://community.plotly.com/t/assining-js-function-to-html-button/5271 "2017-08-07T19:17:29Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![pgaref](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/pgaref/32/1478_2.png) [@pgaref](https://community.plotly.com/u/pgaref)
#### Post date: [August 7, 2017, 7:17pm UTC](https://community.plotly.com/t/assining-js-function-to-html-button/5271/1 "2017-08-07T19:17:29Z")

</div>

Hello there,

I am trying to use some JS to toggle a table in my dash applicaiton.  
I am a bit confused since there does not seem to be an option for that. For instance there is no onClick html property:  
`Allowed arguments: children, id, n_clicks, autoFocus, disabled, form, formAction, name, type, value, accessKey, className, contentEditable, contextMenu, dir, draggable, hidden, lang, spellCheck, style, tabIndex, title`

I guess I could achieve similar functionality with a callback but what if I wanted to assign a JS function to an html buttion/link?

Thanks!

---

<div class="post-metadata">

### Author: ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)
#### Post date: [August 7, 2017, 7:50pm UTC](https://community.plotly.com/t/assining-js-function-to-html-button/5271/2 "2017-08-07T19:50:45Z")

</div>

@pgaref - It’s not possible to do that right now. For now, your options include:

- You could append your own JS file to your dash app ([https://plot.ly/dash/external-resources](https://plot.ly/dash/external-resources))
- Encapsulate the JS logic into a custom Dash component ([https://plot.ly/dash/plugins](https://plot.ly/dash/plugins))

In the future, there might be a couple other options:

- I have a prototype for client-side Dash apps here: [https://github.com/plotly/dash-renderer/pull/7](https://github.com/plotly/dash-renderer/pull/7)
- It might be possible to write a generic Dash component that `exec`s custom JS, Something like:

```auto
# Python interface
JSComponent(src='''
function(input) {
    return {a: input.a*5}t;
}
''', input={'a': 3})

```

```auto
# JS Component Code 
class JSComponent extends Component() {
    constructor(props) {
        super(props)
    }
    componentWillReceiveProps(newProps) {
        newProps.updateProps({output: eval(newProps.src)(newProps.input)});
    }
    render() {
        return null;
    }
}

```
