I want to change what is written in the input tag depending on what was chosen in the select tag.
this is my select tag
<div class="form-group col-lg-4">
<label for="donationType">Donation Type: </label>
<select id="donationType" style="text-transform: capitalize"
name="volunteerProject.donationTypeId" class="form-control">
<option value='0'>Select Donation Type</option>
<s:iterator value="donationTypeList">
<option value='<s:property value="donationTypeId" />'
name='<s:property value="donationType" />'>
<s:property value="donationType" />
</option>
</s:iterator>
</select>
</div>
and this is my input tag
<div class="form-group col-lg-3" id="vpDonateButtonLabelDiv">
<label for="vpTitle">Button Label</label> <input
type="text" class="form-control" id="vpDonateButtonLabel"
name="volunteerProject.donateButtonLabel"
placeholder="Enter button label" maxlength="50" required />
</div>
and here's my javascript code
$('#donationType').change( function() {
var donationType = $(this).val();
if (donationType != 0) {
if (donationType == 1){
$("#vpDonateButtonLabelDiv").append('Donate');
} else if (donationType == 2) {
$("#vpDonateButtonLabelDiv").append('Volunteer');
} else if (donationType == 3) {
$("#vpDonateButtonLabelDiv").append('Share');
} else if (donationType == 5) {
$("#vpDonateButtonLabelDiv").append('Tweet');
}
} else {
$("#vpDonateButtonLabelDiv").append('');
}
});
However, it is not working. What did I miss here? or is my method wrong? Thanks a lot