Topic: chance value of select option with javascript
Taomgirl pro asked 6 years ago
how do I change the value of the select option with javascript outside of user select?
When page loads, I read database and need to restore a previously selected value. I see this code for this has a wrapper and uses class = active but I don't know how to manipulate this directly
<divclassName="form-group"> <selectid="selectCatg"class="mdb-select md-form"value={this.state.catgObj.cid}requiredonChange={(event) =>this.handleCatgChange(event.target)}> {/* this.handleCatgChange(event.target.value)} */} <optionvalue=""disabledselected>Choose category</option> <optionvalue="1">{this.state.catgArr[0]}</option> <optionvalue="2">{this.state.catgArr[1]}</option> <optionvalue="3">{this.state.catgArr[2]}</option> <optionvalue="4">{this.state.catgArr[3]}</option> <optionvalue="5">{this.state.catgArr[4]}</option> <optionvalue="6">{this.state.catgArr[5]}</option> </select> <label>Blog Category</label> </div>
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Status
Opened
Specification of the issue
- ForumUser: Pro
- Premium support: No
- Technology: MDB jQuery
- MDB Version: 4.5.10
- Device: mac
- Browser: Chrome
- OS: ios
- Provided sample code: Yes
- Provided link: No
Piotr Glejzer staff commented 6 years ago
Hi, I have a question for you. Are you using react or jquery version? Best, PiotrTaomgirl pro commented 6 years ago
Jquery but with react. I figured it out but it would have great if the site explained a bit more. I will come back here and add notes with solutionTaomgirl pro commented 6 years ago
Jquery but with react. I figured it out but it would have great if the site explained a bit more. I will come back here and add notes with solutionTaomgirl pro commented 6 years ago
Jquery but with react. I figured it out but it would have great if the site explained a bit more. I will come back here and add notes with solution