Reputation: 105
Ok, well basically I have a jquery dialog, in that dialog it asks questions such as, are you planning to stay on campus, are you an in-state/out-of-state student, and how many years are you planning on attending. Based on the users selection, I want it to total up the cost by the value of (tutuion + Room & Board) * years based on the dropdowns.
This is what I have so far..
if ( bValid ) {
$( "#users tbody" ).append( "<tr>" +
"<td>" + username.val() + "</td>" +
"<td>" + $('#studenttut>option:selected').val() + "</td>" +
"<td>" + $('#campusrb>option:selected').val() + "</td>" +
"<td>" + $('#yearsatten>option:selected').val() + "</td>" +
"</tr>" );
$( this ).dialog( "close" );
}
},
Those are my values in jquery, is there a simple equation I can throw in to calculate the total cost of college? Please and Thank you.
Upvotes: 0
Views: 88
Reputation: 732
If you want to add many values in javascript you must use parseint()
Example:
total = parseInt(student.opt1)+parseInt(student.opt2);
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/parseInt
Upvotes: 1