How can i give one element of a dropdown list a value, and another element a different value? I'm trying to output the different values into a input field when selected. The following is just a visual, so you understand the problem.
<label>Dropdown-List</label>
<select class="form-control" onchange="handicap();">
<option id="c1">Example (5)</option>
<option id="c2">Example (10)</option>
<input type="text" class="form-control" id="cap">
function handicap() {
var cap1 = document.getElementById('c1');
var cap2 = document.getElementById('c2');
if (cap1) {
document.getElementById('cap').value = 5;
}
else {
document.getElementById('cap').value = 10;
}
}
Aucun commentaire:
Enregistrer un commentaire