Reactjs: How can I print the selection item in my webpage?How to turn on/off ReactJS 'development mode'?How do you validate the PropTypes of a nested object in ReactJS?How to use radio buttons in ReactJS?ReactJS - how to use commentsHow can I access a hover state in reactjs?How to set default Checked in checkbox ReactJS?Cannot update during an existing state transitionHow to add multiple classes to a ReactJS ComponentHow to pass data from child component to its parent in ReactJS?Reactjs: How can I move item base on drop down selection

Fastest way from 8 to 7

Dedicated bike GPS computer over smartphone

What publication claimed that Michael Jackson died in a nuclear holocaust?

In The Incredibles 2, why does Screenslaver's name use a pun on something that doesn't exist in the 1950s pastiche?

Can an open source licence be revoked if it violates employer's IP?

Why is the concept of the Null hypothesis associated with the student's t distribution?

Is it a good security practice to force employees hide their employer to avoid being targeted?

If absolute velocity does not exist, how can we say a rocket accelerates in empty space?

Can you open the door or die? v2

What does BREAD stand for while drafting?

The best in flight meal option for those suffering from reflux

When to use the uncountable form of a noun?

Can I attach a DC blower to intake manifold of my 150CC Yamaha FZS FI engine?

What is Gilligan's full name?

What do you call the action of "describing events as they happen" like sports anchors do?

Why do (or did, until very recently) aircraft transponders wait to be interrogated before broadcasting beacon signals?

A life of PhD: is it feasible?

Was planting UN flag on Moon ever discussed?

How can I find out about the game world without meta-influencing it?

How to deal with an excess of white-space in a CRM UI?

Harley Davidson clattering noise from engine, backfire and failure to start

Nth term of Van Eck Sequence

Convert GE Load Center to main breaker

My mom's return ticket is 3 days after I-94 expires



Reactjs: How can I print the selection item in my webpage?


How to turn on/off ReactJS 'development mode'?How do you validate the PropTypes of a nested object in ReactJS?How to use radio buttons in ReactJS?ReactJS - how to use commentsHow can I access a hover state in reactjs?How to set default Checked in checkbox ReactJS?Cannot update during an existing state transitionHow to add multiple classes to a ReactJS ComponentHow to pass data from child component to its parent in ReactJS?Reactjs: How can I move item base on drop down selection






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















First of all, I am new in reactjs. How can I print the selection item in my webpage? This code print the output in the console but I want to print the output in the webpage screen. How can I do this?



´´´´



import React from 'react';

class FlavorForm extends React.Component
constructor(props)
super(props);
this.state = value: 'coconut';

this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);


handleChange(event)
this.setState(value: event.target.value);


handleSubmit(event)
console.log('Your favorite flavor is: ' + this.state.value);
event.preventDefault();


render()
return (
<form onSubmit=this.handleSubmit>
<label>
Pick your favorite flavor:
<select value=this.state.value onChange=this.handleChange>
<option value="grapefruit">Grapefruit</option>
<option value="lime">Lime</option>
<option value="coconut">Coconut</option>
<option value="mango">Mango</option>
</select>
</label>
<input type="submit" value="Submit" />

</form>
);



export default FlavorForm


´´´´










share|improve this question




























    0















    First of all, I am new in reactjs. How can I print the selection item in my webpage? This code print the output in the console but I want to print the output in the webpage screen. How can I do this?



    ´´´´



    import React from 'react';

    class FlavorForm extends React.Component
    constructor(props)
    super(props);
    this.state = value: 'coconut';

    this.handleChange = this.handleChange.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);


    handleChange(event)
    this.setState(value: event.target.value);


    handleSubmit(event)
    console.log('Your favorite flavor is: ' + this.state.value);
    event.preventDefault();


    render()
    return (
    <form onSubmit=this.handleSubmit>
    <label>
    Pick your favorite flavor:
    <select value=this.state.value onChange=this.handleChange>
    <option value="grapefruit">Grapefruit</option>
    <option value="lime">Lime</option>
    <option value="coconut">Coconut</option>
    <option value="mango">Mango</option>
    </select>
    </label>
    <input type="submit" value="Submit" />

    </form>
    );



    export default FlavorForm


    ´´´´










    share|improve this question
























      0












      0








      0








      First of all, I am new in reactjs. How can I print the selection item in my webpage? This code print the output in the console but I want to print the output in the webpage screen. How can I do this?



      ´´´´



      import React from 'react';

      class FlavorForm extends React.Component
      constructor(props)
      super(props);
      this.state = value: 'coconut';

      this.handleChange = this.handleChange.bind(this);
      this.handleSubmit = this.handleSubmit.bind(this);


      handleChange(event)
      this.setState(value: event.target.value);


      handleSubmit(event)
      console.log('Your favorite flavor is: ' + this.state.value);
      event.preventDefault();


      render()
      return (
      <form onSubmit=this.handleSubmit>
      <label>
      Pick your favorite flavor:
      <select value=this.state.value onChange=this.handleChange>
      <option value="grapefruit">Grapefruit</option>
      <option value="lime">Lime</option>
      <option value="coconut">Coconut</option>
      <option value="mango">Mango</option>
      </select>
      </label>
      <input type="submit" value="Submit" />

      </form>
      );



      export default FlavorForm


      ´´´´










      share|improve this question














      First of all, I am new in reactjs. How can I print the selection item in my webpage? This code print the output in the console but I want to print the output in the webpage screen. How can I do this?



      ´´´´



      import React from 'react';

      class FlavorForm extends React.Component
      constructor(props)
      super(props);
      this.state = value: 'coconut';

      this.handleChange = this.handleChange.bind(this);
      this.handleSubmit = this.handleSubmit.bind(this);


      handleChange(event)
      this.setState(value: event.target.value);


      handleSubmit(event)
      console.log('Your favorite flavor is: ' + this.state.value);
      event.preventDefault();


      render()
      return (
      <form onSubmit=this.handleSubmit>
      <label>
      Pick your favorite flavor:
      <select value=this.state.value onChange=this.handleChange>
      <option value="grapefruit">Grapefruit</option>
      <option value="lime">Lime</option>
      <option value="coconut">Coconut</option>
      <option value="mango">Mango</option>
      </select>
      </label>
      <input type="submit" value="Submit" />

      </form>
      );



      export default FlavorForm


      ´´´´







      reactjs






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 0:07









      Mahmudul HasanMahmudul Hasan

      11




      11






















          2 Answers
          2






          active

          oldest

          votes


















          0














          Just add some html element that is bound to your "value" property, like this:



          render() 
          return (
          <div>
          <h3>Flavor: this.state.value</h3>
          <form onSubmit=this.handleSubmit>
          <label>
          Pick your favorite flavor:
          <select value=this.state.value onChange=this.handleChange>
          <option value="grapefruit">Grapefruit</option>
          <option value="lime">Lime</option>
          <option value="coconut">Coconut</option>
          <option value="mango">Mango</option>
          </select>
          </label>
          <input type="submit" value="Submit" />

          </form>
          </div>
          );






          share|improve this answer























          • Thanks a lot. But I want to show the results after clicking the submit button. How can I do that?

            – Mahmudul Hasan
            Mar 25 at 0:53











          • Show the results where? The state.value changes on each onChange event, so any html element that is bound to it- will show the result, regardless of the form submission. I think that your confusion comes from not understanding that React is "declarative". You can read about it here: codeburst.io/declarative-vs-imperative-programming-a8a7c93d9ad2

            – sheff2k1
            Mar 25 at 1:05


















          0














          Not sure of the exact behavior you want, but you could keep a boolean that your state that shows/hides the text:



          import React from 'react';

          class FlavorForm extends React.Component
          constructor(props)
          super(props);
          this.state =
          value: 'coconut',
          showFlavor: false // this controls whether or not the text is shown
          ;

          this.handleChange = this.handleChange.bind(this);
          this.handleSubmit = this.handleSubmit.bind(this);


          handleChange(event)
          this.setState(value: event.target.value);


          handleSubmit(event)
          // console.log('Your favorite flavor is: ' + this.state.value);
          event.preventDefault();
          this.setState( showFlavor: true ); // toggle on our boolean, note that in this example it never gets set back to false


          render()
          return (
          <form onSubmit=this.handleSubmit>
          <label>
          Pick your favorite flavor:
          <select value=this.state.value onChange=this.handleChange>
          <option value="grapefruit">Grapefruit</option>
          <option value="lime">Lime</option>
          <option value="coconut">Coconut</option>
          <option value="mango">Mango</option>
          </select>
          </label>
          <input type="submit" value="Submit" />

          // text appears here only when state.showFlavor is true
          <span>this.state.showFlavor ? `Your favorite flavor is: $this.state.value` : ''</span>
          </form>
          );







          share|improve this answer























          • Thanks. This is what I expecting as output. Thanks a lot

            – Mahmudul Hasan
            Mar 25 at 16:36











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55329780%2freactjs-how-can-i-print-the-selection-item-in-my-webpage%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Just add some html element that is bound to your "value" property, like this:



          render() 
          return (
          <div>
          <h3>Flavor: this.state.value</h3>
          <form onSubmit=this.handleSubmit>
          <label>
          Pick your favorite flavor:
          <select value=this.state.value onChange=this.handleChange>
          <option value="grapefruit">Grapefruit</option>
          <option value="lime">Lime</option>
          <option value="coconut">Coconut</option>
          <option value="mango">Mango</option>
          </select>
          </label>
          <input type="submit" value="Submit" />

          </form>
          </div>
          );






          share|improve this answer























          • Thanks a lot. But I want to show the results after clicking the submit button. How can I do that?

            – Mahmudul Hasan
            Mar 25 at 0:53











          • Show the results where? The state.value changes on each onChange event, so any html element that is bound to it- will show the result, regardless of the form submission. I think that your confusion comes from not understanding that React is "declarative". You can read about it here: codeburst.io/declarative-vs-imperative-programming-a8a7c93d9ad2

            – sheff2k1
            Mar 25 at 1:05















          0














          Just add some html element that is bound to your "value" property, like this:



          render() 
          return (
          <div>
          <h3>Flavor: this.state.value</h3>
          <form onSubmit=this.handleSubmit>
          <label>
          Pick your favorite flavor:
          <select value=this.state.value onChange=this.handleChange>
          <option value="grapefruit">Grapefruit</option>
          <option value="lime">Lime</option>
          <option value="coconut">Coconut</option>
          <option value="mango">Mango</option>
          </select>
          </label>
          <input type="submit" value="Submit" />

          </form>
          </div>
          );






          share|improve this answer























          • Thanks a lot. But I want to show the results after clicking the submit button. How can I do that?

            – Mahmudul Hasan
            Mar 25 at 0:53











          • Show the results where? The state.value changes on each onChange event, so any html element that is bound to it- will show the result, regardless of the form submission. I think that your confusion comes from not understanding that React is "declarative". You can read about it here: codeburst.io/declarative-vs-imperative-programming-a8a7c93d9ad2

            – sheff2k1
            Mar 25 at 1:05













          0












          0








          0







          Just add some html element that is bound to your "value" property, like this:



          render() 
          return (
          <div>
          <h3>Flavor: this.state.value</h3>
          <form onSubmit=this.handleSubmit>
          <label>
          Pick your favorite flavor:
          <select value=this.state.value onChange=this.handleChange>
          <option value="grapefruit">Grapefruit</option>
          <option value="lime">Lime</option>
          <option value="coconut">Coconut</option>
          <option value="mango">Mango</option>
          </select>
          </label>
          <input type="submit" value="Submit" />

          </form>
          </div>
          );






          share|improve this answer













          Just add some html element that is bound to your "value" property, like this:



          render() 
          return (
          <div>
          <h3>Flavor: this.state.value</h3>
          <form onSubmit=this.handleSubmit>
          <label>
          Pick your favorite flavor:
          <select value=this.state.value onChange=this.handleChange>
          <option value="grapefruit">Grapefruit</option>
          <option value="lime">Lime</option>
          <option value="coconut">Coconut</option>
          <option value="mango">Mango</option>
          </select>
          </label>
          <input type="submit" value="Submit" />

          </form>
          </div>
          );







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 25 at 0:18









          sheff2k1sheff2k1

          536519




          536519












          • Thanks a lot. But I want to show the results after clicking the submit button. How can I do that?

            – Mahmudul Hasan
            Mar 25 at 0:53











          • Show the results where? The state.value changes on each onChange event, so any html element that is bound to it- will show the result, regardless of the form submission. I think that your confusion comes from not understanding that React is "declarative". You can read about it here: codeburst.io/declarative-vs-imperative-programming-a8a7c93d9ad2

            – sheff2k1
            Mar 25 at 1:05

















          • Thanks a lot. But I want to show the results after clicking the submit button. How can I do that?

            – Mahmudul Hasan
            Mar 25 at 0:53











          • Show the results where? The state.value changes on each onChange event, so any html element that is bound to it- will show the result, regardless of the form submission. I think that your confusion comes from not understanding that React is "declarative". You can read about it here: codeburst.io/declarative-vs-imperative-programming-a8a7c93d9ad2

            – sheff2k1
            Mar 25 at 1:05
















          Thanks a lot. But I want to show the results after clicking the submit button. How can I do that?

          – Mahmudul Hasan
          Mar 25 at 0:53





          Thanks a lot. But I want to show the results after clicking the submit button. How can I do that?

          – Mahmudul Hasan
          Mar 25 at 0:53













          Show the results where? The state.value changes on each onChange event, so any html element that is bound to it- will show the result, regardless of the form submission. I think that your confusion comes from not understanding that React is "declarative". You can read about it here: codeburst.io/declarative-vs-imperative-programming-a8a7c93d9ad2

          – sheff2k1
          Mar 25 at 1:05





          Show the results where? The state.value changes on each onChange event, so any html element that is bound to it- will show the result, regardless of the form submission. I think that your confusion comes from not understanding that React is "declarative". You can read about it here: codeburst.io/declarative-vs-imperative-programming-a8a7c93d9ad2

          – sheff2k1
          Mar 25 at 1:05













          0














          Not sure of the exact behavior you want, but you could keep a boolean that your state that shows/hides the text:



          import React from 'react';

          class FlavorForm extends React.Component
          constructor(props)
          super(props);
          this.state =
          value: 'coconut',
          showFlavor: false // this controls whether or not the text is shown
          ;

          this.handleChange = this.handleChange.bind(this);
          this.handleSubmit = this.handleSubmit.bind(this);


          handleChange(event)
          this.setState(value: event.target.value);


          handleSubmit(event)
          // console.log('Your favorite flavor is: ' + this.state.value);
          event.preventDefault();
          this.setState( showFlavor: true ); // toggle on our boolean, note that in this example it never gets set back to false


          render()
          return (
          <form onSubmit=this.handleSubmit>
          <label>
          Pick your favorite flavor:
          <select value=this.state.value onChange=this.handleChange>
          <option value="grapefruit">Grapefruit</option>
          <option value="lime">Lime</option>
          <option value="coconut">Coconut</option>
          <option value="mango">Mango</option>
          </select>
          </label>
          <input type="submit" value="Submit" />

          // text appears here only when state.showFlavor is true
          <span>this.state.showFlavor ? `Your favorite flavor is: $this.state.value` : ''</span>
          </form>
          );







          share|improve this answer























          • Thanks. This is what I expecting as output. Thanks a lot

            – Mahmudul Hasan
            Mar 25 at 16:36















          0














          Not sure of the exact behavior you want, but you could keep a boolean that your state that shows/hides the text:



          import React from 'react';

          class FlavorForm extends React.Component
          constructor(props)
          super(props);
          this.state =
          value: 'coconut',
          showFlavor: false // this controls whether or not the text is shown
          ;

          this.handleChange = this.handleChange.bind(this);
          this.handleSubmit = this.handleSubmit.bind(this);


          handleChange(event)
          this.setState(value: event.target.value);


          handleSubmit(event)
          // console.log('Your favorite flavor is: ' + this.state.value);
          event.preventDefault();
          this.setState( showFlavor: true ); // toggle on our boolean, note that in this example it never gets set back to false


          render()
          return (
          <form onSubmit=this.handleSubmit>
          <label>
          Pick your favorite flavor:
          <select value=this.state.value onChange=this.handleChange>
          <option value="grapefruit">Grapefruit</option>
          <option value="lime">Lime</option>
          <option value="coconut">Coconut</option>
          <option value="mango">Mango</option>
          </select>
          </label>
          <input type="submit" value="Submit" />

          // text appears here only when state.showFlavor is true
          <span>this.state.showFlavor ? `Your favorite flavor is: $this.state.value` : ''</span>
          </form>
          );







          share|improve this answer























          • Thanks. This is what I expecting as output. Thanks a lot

            – Mahmudul Hasan
            Mar 25 at 16:36













          0












          0








          0







          Not sure of the exact behavior you want, but you could keep a boolean that your state that shows/hides the text:



          import React from 'react';

          class FlavorForm extends React.Component
          constructor(props)
          super(props);
          this.state =
          value: 'coconut',
          showFlavor: false // this controls whether or not the text is shown
          ;

          this.handleChange = this.handleChange.bind(this);
          this.handleSubmit = this.handleSubmit.bind(this);


          handleChange(event)
          this.setState(value: event.target.value);


          handleSubmit(event)
          // console.log('Your favorite flavor is: ' + this.state.value);
          event.preventDefault();
          this.setState( showFlavor: true ); // toggle on our boolean, note that in this example it never gets set back to false


          render()
          return (
          <form onSubmit=this.handleSubmit>
          <label>
          Pick your favorite flavor:
          <select value=this.state.value onChange=this.handleChange>
          <option value="grapefruit">Grapefruit</option>
          <option value="lime">Lime</option>
          <option value="coconut">Coconut</option>
          <option value="mango">Mango</option>
          </select>
          </label>
          <input type="submit" value="Submit" />

          // text appears here only when state.showFlavor is true
          <span>this.state.showFlavor ? `Your favorite flavor is: $this.state.value` : ''</span>
          </form>
          );







          share|improve this answer













          Not sure of the exact behavior you want, but you could keep a boolean that your state that shows/hides the text:



          import React from 'react';

          class FlavorForm extends React.Component
          constructor(props)
          super(props);
          this.state =
          value: 'coconut',
          showFlavor: false // this controls whether or not the text is shown
          ;

          this.handleChange = this.handleChange.bind(this);
          this.handleSubmit = this.handleSubmit.bind(this);


          handleChange(event)
          this.setState(value: event.target.value);


          handleSubmit(event)
          // console.log('Your favorite flavor is: ' + this.state.value);
          event.preventDefault();
          this.setState( showFlavor: true ); // toggle on our boolean, note that in this example it never gets set back to false


          render()
          return (
          <form onSubmit=this.handleSubmit>
          <label>
          Pick your favorite flavor:
          <select value=this.state.value onChange=this.handleChange>
          <option value="grapefruit">Grapefruit</option>
          <option value="lime">Lime</option>
          <option value="coconut">Coconut</option>
          <option value="mango">Mango</option>
          </select>
          </label>
          <input type="submit" value="Submit" />

          // text appears here only when state.showFlavor is true
          <span>this.state.showFlavor ? `Your favorite flavor is: $this.state.value` : ''</span>
          </form>
          );








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 25 at 1:08









          miyumiyu

          2327




          2327












          • Thanks. This is what I expecting as output. Thanks a lot

            – Mahmudul Hasan
            Mar 25 at 16:36

















          • Thanks. This is what I expecting as output. Thanks a lot

            – Mahmudul Hasan
            Mar 25 at 16:36
















          Thanks. This is what I expecting as output. Thanks a lot

          – Mahmudul Hasan
          Mar 25 at 16:36





          Thanks. This is what I expecting as output. Thanks a lot

          – Mahmudul Hasan
          Mar 25 at 16:36

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55329780%2freactjs-how-can-i-print-the-selection-item-in-my-webpage%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현