content logo

React Forms:

Simple Drop Down Menu to Change Text using React

If you have an online shop on your website, this post is useful for you. It is the Simple Drop Down Menu to Change Text using React with a simple design. Because of its simplicity, this Simple Menu using React fits with most sorts of websites. So, you can use it for your page with no concern. Most websites use this React Drop Down Menu in order to let their customers choose their payment methods. Additionally, this code is helpful for online shops, and customers can choose the color for their clothes.

You can look at the following preview of this Javascript Menu Code to realize its performance. As it appears, this code has a white background, and there is a pop-up field above the page. This field has a grey background with black writing. When you tap on this bottom, you will face various colors that you can choose from. After selecting your considered color or payment method, it will be written down in black color. Generally, this Free React Text Change is so useful for all kinds of websites and you can utilize it for your page to gain more viewers.

#

React Drop Down Form

#

Simple Form using React

#

Javascript Form Code

#

React Form Text Change

<!-- This script got from frontendfreecode.com -->
<div id="root">
</div><a style="font-size: 8pt; text-decoration: none" target="_blank" href="http://frontendfreecode.com">Free Frontend</a>
                                                                            
select {
  font-size: 1.5em;
}
p {
  font-size: 2em;
  font-family: sans-serif;
}
class FruitSelector extends React.Component {
  constructor() {
    super();
    this.handleChange = this.handleChange.bind(this);
    this.state = {
      selectValue: 'Orange' };
  }
  handleChange(event) {
    this.setState({ selectValue: event.target.value });
  }
  render() {
    var message = 'You selected ' + this.state.selectValue;
    return /*#__PURE__*/(
      React.createElement("div", null, /*#__PURE__*/
      React.createElement("select", {
        value: this.state.selectValue,
        onChange: this.handleChange }, /*#__PURE__*/
      React.createElement("option", { value: "Orange" }, "Orange"), /*#__PURE__*/
      React.createElement("option", { value: "Pineapple" }, "Pineapple"), /*#__PURE__*/
      React.createElement("option", { value: "Cherry" }, "Cherry"), /*#__PURE__*/
      React.createElement("option", { value: "Banana" }, "Banana"), /*#__PURE__*/
      React.createElement("option", { value: "Pear" }, "Pear"), /*#__PURE__*/
      React.createElement("option", { value: "Date" }, "Date")), /*#__PURE__*/
      React.createElement("p", null, message)));
  }}
ReactDOM.render( /*#__PURE__*/
React.createElement(FruitSelector, null),
document.getElementById('root'));
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react-dom.min.js'></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- This script got from frontendfreecode.com -->

<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react-dom.min.js'></script>
<style>
select {
  font-size: 1.5em;
}
p {
  font-size: 2em;
  font-family: sans-serif;
}
</style>

</head>
<body>
<div id="root">
</div><div id="bcl"><a style="font-size:8pt;text-decoration:none;" href="http://www.devanswer.com">Free Frontend</a></div>
<script>
class FruitSelector extends React.Component {
  constructor() {
    super();
    this.handleChange = this.handleChange.bind(this);
    this.state = {
      selectValue: 'Orange' };
  }
  handleChange(event) {
    this.setState({ selectValue: event.target.value });
  }
  render() {
    var message = 'You selected ' + this.state.selectValue;
    return /*#__PURE__*/(
      React.createElement("div", null, /*#__PURE__*/
      React.createElement("select", {
        value: this.state.selectValue,
        onChange: this.handleChange }, /*#__PURE__*/
      React.createElement("option", { value: "Orange" }, "Orange"), /*#__PURE__*/
      React.createElement("option", { value: "Pineapple" }, "Pineapple"), /*#__PURE__*/
      React.createElement("option", { value: "Cherry" }, "Cherry"), /*#__PURE__*/
      React.createElement("option", { value: "Banana" }, "Banana"), /*#__PURE__*/
      React.createElement("option", { value: "Pear" }, "Pear"), /*#__PURE__*/
      React.createElement("option", { value: "Date" }, "Date")), /*#__PURE__*/
      React.createElement("p", null, message)));
  }}
ReactDOM.render( /*#__PURE__*/
React.createElement(FruitSelector, null),
document.getElementById('root'));
</script>

</body>
</html>
Preview