/    Sign up×
Community /Pin to ProfileBookmark

Trying to add two add values from different javascript arrays…

I am deriving two different values from these scripts.

[B]Script #1…[/B]

[CODE]//JS for Potential Gen Ed TOC
$(function($) {
$(‘#CourseMenu select’).change(function() {
var sum = 0;
$(‘#CourseMenu select’).each(function(idx, elm) {
sum += parseFloat(elm.value, 10);
});

$(‘#total_potential’).html(Math.min(sum,72).toFixed(2));
});
});[/CODE]

[B]Script #2…[/B]

[CODE]//JS for Potential Gen Ed TOC from Electives only
$(function($) {
$(‘#CourseMenu_Electives select’).change(function() {
var sum = 0;
$(‘#CourseMenu_Electives select’).each(function(idx, elm) {
sum += parseFloat(elm.value, 10);
});

$(‘#total_potential’).html(Math.min(sum,33).toFixed(2));
});
});[/CODE]

[B]However, I’d like to pull the data from both of these and have the result display in the following HTML…[/B]

[code=html] <p><fieldset id=”PotentialTOC”>
<legend style=”font-weight: bold; font-size: 140%;”>Potential TOC Evaluation Results</legend>

<div id=”Results” style=”text-align:left; font-family: ‘Century Gothic’, Gadget, sans-serif; font-size:14px;”><br />
<div>
<h2><span id=”span”></span>
Potential Gen Ed TOC:&nbsp;&nbsp;<span id=”total_potential”></span>
<br />
Potential Money Saved: $<span id=”total_money”></span>
<br />
Potential Class Time Saved:&nbsp;&nbsp;<span id=”total_time”></span> weeks
</fieldset></p>[/code]

Here’s a [URL=”http://jsfiddle.net/jlnewnam/fhL3s/1/”]jsfiddle [/URL]to show what I’ve done so far… I can’t transfer more than 33 elective credits and no more than 72 credits overall. I have the scripts laid out well, but again, need them combined to spit out one value.

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @jlnewnam spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...