Well, not with that many addons. My own most complicated sums seem to come out in RegEx constructors like
expr = new RegExp ("<td>\\[dot" + count + "\\] *(\\[" + langname[count] + "\\])? *(=\w\w)? *","g");
where "count" is what it looks like, an iteration of a "for..." loop. In the code snippet that I coincidentally asked about a few days ago, it doesn't get any fancier than
newstring = '<img src = "http://www.example.com/pictures/smallgifs/dot7' + pagenum + '.gif" width = "1" height = "1" alt = "">';
document.getElementById("clicker").innerHTML = newstring;
where pagenum is a preset integer. Doesn't have to be an integer, though. An earlier variant of the same routine used
window.navigator.language
or
window.navigator.userLanguage
(form inconveniently depends on browser) and plugged in the result approximately where I had "pagenum" above. But you see already that you can have more than one +
Note alternation between single and double quotes, since you need to produce output containing literal quotes. The alternative-- which is perfectly legitimate but visually more confusing-- is to escape each literal quotation mark.
If you're using innerHTML, the anchor equivalent would be something like
<span id = "javahere"> </span>
Put that in place ahead of time. Its sole function is to create a place for you to pop the result into.
Now do whatever you have to do to get your two "cost" variables, and make sure they're in the correct form-- numerical value in the appropriate range, correct number of decimal places etc-- before you plug them into the code. You want integers, I guess, since your code follows each one with %2e and two digits. They will magically change back into strings if you add them to a string variable.
mystring = '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick-subscriptions&business=xxxxxxxxxxxx&lc=US&item_name=Auto%20Proxy%20Posting&no_note=1&no_shipping=2&a1=' + cost1 + '%2e00&p1=1&t1=M&src=1&a3=' + cost2 + '%2e11&p3=1&t3=M&currency_code=USD&bn=PP%2dSubscriptionsBF%3abtn_subscrib">';
document.getElementById("javahere").innerHTML = mystring;
Result:
<span id = "javahere"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick-subscriptions&business=xxxxxxxxxxxx&lc=US&item_name=Auto%20Proxy%20Posting&no_note=1&no_shipping=2&a1=
cost1%2e00&p1=1&t1=M&src=1&a3=
cost2%2e11&p3=1&t3=M&currency_code=USD&bn=PP%2dSubscriptionsBF%3abtn_subscrib"></span>
To do it properly, you should include the anchor text and closing </a> inside the span, and remember to include them in the "mystring" otuput. In fact you can do both together:
<span id = "javahere">anchortext</span>
mystring = document.getElementById("javahere").value;
newstring = '<a href {all the stuff you had before, winding up with} abtn_subscrib">' + mystring + '</a>';
document.getElementById("javahere").innerHTML = newstring;
AND if your <a href> also happened to have an id, you could now use the same function to pull out the anchor text and change it separately. But let's not go overboard.