JSFiddle - React, Tailwind, and code Playground

by nilgundag

HTML

<script src="http://fb.me/react-with-addons-0.11.0.js"></script>
<script src="http://fb.me/JSXTransformer-0.11.0.js"></script>
<script src="http://fb.me/react-js-fiddle-integration.js"></script>

JavaScript 1.7

/** @jsx React.DOM */

var Hello = React.createClass({
    getInitialState: function() {
    return {
        value: 'C'
    }
    },
    onChange: function(event) {
        console.log("onchange:, ", event);
        var items =this.getDOMNode().querySelectorAll('option') ;
        for (var i = 0; i < items.length; i += 1) {
            console.log(i, items[i].selected, items[i].value);
            if (items[i].selected) {
                this.setState({value:items[i].value});
            }
        }
        
    },
    render: function() {
           
        return <div>Hello {this.props.name}
        <p>Value: {this.state.value}</p>
        
         <select onChange={this.onChange} value={this.state.value} >
    <option value="A">Apple</option>
    <option value="B">Banana</option>
    <option value="C">Cranberry</option>
  </select>
        
        </div>;
    }
});
 
React.renderComponent(<Hello name="World" />, document.body);