elseif should be
else if
(you need a space in between).
Also, in your HTML, your <OPTION> tags need to have those values as well and don't forget that js is case sensitive:
<option value="institutional memberhip">Institutional Memberhip</option>
<option value="individual membership">Individual Membership</option>
hielo
Veteran Poster
1,124 posts since Dec 2007
Reputation Points: 116
Solved Threads: 244
You should check what value is actually returned from 'item_name.val()'. Alert it to see what actually is returned? (add alert(value) right after line 3 in your javascript code.) The reason is that it looks like your if-else statement is always false; as a result, it returns only else.
Taywin
Posting Virtuoso
1,727 posts since Apr 2010
Reputation Points: 229
Solved Threads: 239
try changing:
var value = $('#item_name').val();
to: var value = $('option:selected',this).attr('value');
hielo
Veteran Poster
1,124 posts since Dec 2007
Reputation Points: 116
Solved Threads: 244
Don't seem to have any problem in my opinion. The this refers to $('#item_name') anyway.
Taywin
Posting Virtuoso
1,727 posts since Apr 2010
Reputation Points: 229
Solved Threads: 239
What you have now is fine. Also, regarding:
Humm ... well, i made the changes and amount does get updated but only to the last value available in the select list. So, for example:
$(document).ready(function () {
$('#item_name').change(function () {
var value = $('#item_name').val();
if(value == "institutional memberhip"){
$("#amount").val("349.00");
} else if(value == "associate memberhip"){
$("#amount").val("99.00");
} else {
$("#amount").val("37.45");
}
});
});
The problem with that code is that you misspelled membership in you if clauses. Otherwise it would also work.
hielo
Veteran Poster
1,124 posts since Dec 2007
Reputation Points: 116
Solved Threads: 244