Skip to content

Commit

Permalink
Display value for controlled select and textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Dail committed Jan 2, 2017
1 parent f16e67e commit 62c3c4b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
7 changes: 6 additions & 1 deletion fixtures/selects/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
padding: 20px;
width: 45%;
}

.hint {
padding-left: 8px;
}
</style>
</head>
<body>
Expand Down Expand Up @@ -55,8 +59,9 @@
<option value="">Select a color</option>
<option value="red">Red</option>
<option value="blue">Blue</option>
<option value="gree">Green</option>
<option value="green">Green</option>
</select>
<span className="hint">Value: {this.state.value}</span>
</fieldset>

<fieldset>
Expand Down
37 changes: 25 additions & 12 deletions fixtures/textareas/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,26 @@
width: 100%;
}

form {
.container {
max-width: 900px;
margin: 0 auto;
text-align: center;
}

.output {
word-wrap: break-word;
max-width: 780px;
margin: auto;
}

fieldset {
border: 1px solid #ccc;
display: inline-block;
padding: 20px;
vertical-align: top;
width: 45%;
}

</style>
</head>
<body>
Expand All @@ -55,17 +62,23 @@

render() {
return (
<form>
<fieldset>
<legend>Controlled</legend>
<textarea value={this.state.value} onChange={this.onChange.bind(this)} />
</fieldset>

<fieldset>
<legend>Uncontrolled</legend>
<textarea defaultValue="" />
</fieldset>
</form>
<div className='container'>
<form>
<fieldset>
<legend>Controlled</legend>
<textarea value={this.state.value} onChange={this.onChange.bind(this)} />
</fieldset>

<fieldset>
<legend>Uncontrolled</legend>
<textarea defaultValue="" />
</fieldset>
</form>
<h4>Controlled Output:</h4>
<div className='output'>
{this.state.value}
</div>
</div>
)
}
}
Expand Down

0 comments on commit 62c3c4b

Please sign in to comment.