0

I have dropdown select that consumes it options from a REST API, which is populated with those values. What I want to do is insert default option value into the dropdown select. This is my code snippet, but the default value "Select Bill Type" does not show:

<select className="form-control" id="billType" value={audit.crgBilltype.Value} onChange={(e) => this.handleBillTypeChange(e)} >
            <option selected="selected">Select Bill Type</option>
              {Object.keys(billTypeToIdMap).map(id => <option value={id} key={id}>{billTypeToIdMap[id]}</option>)}
            </select>

Could I get some help with this?

user1724708
  • 1,409
  • 7
  • 31
  • 53
  • It doesn't show as in you cannot see it physically on the page or the is the problem you're not getting the value? – borbesaur Oct 26 '18 at 15:16
  • am getting all my values from the REST API (All good) ... I just want to include an option selected with the Text "Select Bill Type". ...Select Bill Type is not whats showing – user1724708 Oct 26 '18 at 15:19
  • @user1724708 I think what borbesaur was saying is that your option for Select Bill Type doesn't have its value attribute set and they were wondering if that might be the issue. But you are saying no option is displayed in the UI. – Jonathan Rys Oct 26 '18 at 15:22
  • You are correct. Look at Hello Earth has has the answer below. – borbesaur Oct 26 '18 at 15:23
  • you are working with JSX and not HTML, try to look at this link, they already answerd the question: [React JSX: selecting “selected” on selected – Anass TIssir Oct 26 '18 at 15:22

0 Answers0