Performing mathematical operations on attribute value
<p>I am attempting to perform mathematical operations with JavaScript on values obtained from an attribute. The attribute is created via a PHP loop. I will give an example of one of the html tags containing the attributes, but keep in mind that there are many of these tags which contain unique attribute values.</p>

<p><strong>The HTML:</strong></p>

<pre><code>&lt;a href="secondary_imgs.php..." mwidth="593"&gt;&lt;/a&gt;
</code></pre>

<p><strong>The JavaScript(jQuery):</strong></p>

<pre><code>    $("a[href^='secondary_imgs.php']").click(function(){
        var pageWidth = $(window).width();
        var maxshadowWidth = (Math.floor(pageWidth * 0.91808874)) - 2;
        var mWidth = $(this).attr("mwidth");
        var maxSecondaryWidth = mWidth + 60;
        alert (maxSecondaryWidth);
        if(maxSecondaryWidth &lt;= maxshadowWidth) {
            var shadowWidth = maxSecondaryWidth;
        } else {
            var shadowWidth = maxshadowWidth;
        }
        var shadowboxrel = 'shadowbox;width=' + shadowWidth;
        $(this).attr('rel', shadowboxrel);
</code></pre>

<p>The operation doesn't seem to be working, and I have a feeling it has to do with my lack of experience using mathematical operations in javascript. In this case, I think something is wrong with my method of using the attribute value, <em>in</em> the mathematical operation.</p>

<p>For example, the above <code>width</code> attribute is defined as <code>593</code>. I define the <code>maxSecondaryWidth</code> as <code>mWidth + 60</code>. I fired an alert to see what value I was getting. It should have been shown as <code>653</code>, yet the value that is 'alerted' is <code>59360</code>. Obviously I don't understand how to add, as the <code>+</code> is concatenating the two values, as opposed to adding them together. Could it have to do with needing to transform the attribute value from a string into an integer?</p>
