Passing value of text field, with a PHP variable name, to Javascript
<p>Good evening. I have creating a PHP page will go through a directory and insert pictures into a table. With these pictures will be a select dropdown box and a quantity text input. Each form element is named based on the file's name when it is created. I cannot seem to pass the quantity value to javascript. HELP (please). My code is posted below.</p>

<pre><code>for ($i=0; $i&lt;count($files); $i++) {
    echo $_POST[bandSelect];
    if ($i%3 ==0 &amp;&amp; $i!=0) {
        echo '&lt;/tr&gt;&lt;tr&gt;';
    }
    $pricewallets = "$7.50"; $price3x5 = "$2.00";
    $price4x6 = "$3.00";     $price5x7 = "$4.00";
    $price8x10 = "$9.00";    $price11x14 = "$14.75";
    $price12x18 = "$20.00";  $price16x20 = "$27.00";  
    $price18x24 = "$28.20";

    $num = $files[$i];
    list($width, $height, $type, $attr) = getimagesize($files[$i]);
    echo '&lt;td style="text-align:center;"&gt;&lt;a href="'.$num.'" target="_blank"&gt;
        &lt;img src="'.$num.'" width ="'.($width/4).'" alt="random image"&gt;&lt;/a&gt;';

    $fileName = basename($num);
    $qty = $num."qty";
    echo "&lt;br /&gt;".$fileName;
    echo '&lt;br /&gt;&lt;select name="'.$num.'" id="'.$num.'"&gt;
        &lt;option value="'.$num.'Wallets"&gt;Wallets (8)&lt;/option&gt;
        &lt;option value="'.$num.'3x5"&gt;3" x 5"&lt;/option&gt;
        &lt;option value="'.$num.'4x6"&gt;4" x 6"&lt;/option&gt;
        &lt;option value="'.$num.'5x7"&gt;5" x 7"&lt;/option&gt;
        &lt;option value="'.$num.'11x14"&gt;11" x 14"&lt;/option&gt;
        &lt;option value="'.$num.'12x18"&gt;12" x 18"&lt;/option&gt;
        &lt;option value="'.$num.'16x20"&gt;16" x 20"&lt;/option&gt;
        &lt;option value="'.$num.'18x24"&gt;18" x 24"&lt;/option&gt;
        &lt;/select&gt;';
    echo '&lt;input type="text" name="'.$qty.'" id="'.$qty.'" size="1" value="0" /&gt;
        &lt;br /&gt;
        &lt;input type="button" name="addCart" value="Add to cart" onclick="addcart( \''.$num.'\',\''.$fileName.'\',\''.$qty.'\')" /&gt;
    &lt;/td&gt;';
}
</code></pre>

<p>Here is my Javascript</p>

<pre><code>function addcart(name, filename, qty)
{
var e = document.getElementById(name);
var strUser = e.options[e.selectedIndex].text;
var price;
var salePrice;
switch (strUser)
{
case "Wallets (8)":
    salePrice = 7.5;
    price = "$7.50";
    break;

case "3\" x 5\"":
    salePrice = 2;
    price = "$2.00";
    break;

case "4\" x 6\"":
    salePrice = 3;
    price = "$3.00";
    break;

case "5\" x 7\"":
    salePrice = 4;
    price = "$4.00";
    break;

case "8\" x 10\"":
    salePrice = 9;
    price = "$9.00";
    break;

case "3\" x 5\"":
    salePrice = 2;
    price = "$2.00";
    break;

case "11\" x 14\"":
    salePrice = 14.75;
    price = "$14.75";
    break;

case "12\" x 18\"":
    salePrice = 20;
    price = "$20.00";
    break;

case "16\" x 20\"":
    salePrice = 27;
    price = "$27.00";
    break;

case "18\" x 24\"":
    salePrice = 28.5;
    price = "$28.50";
    break;
}
var cartTotal=document.picSelect.cart.value;
if(strUser!=="Wallets (8)")
{
document.picSelect.cart.value = cartTotal + " " + filename + " " + strUser + "\t " + price + " x " + qty + "\n";    
}
else
{
document.picSelect.cart.value = cartTotal + " " + filename + " " + strUser + " " + price + " x " + qty + "\n";
}
document.picSelect.Total.value = parseFloat(document.picSelect.Total.value) + salePrice * qty;
textTotal.innerHTML = "Your current  total is:\n\t$" +     parseFloat(document.picSelect.Total.value).toFixed(2);



 }
</code></pre>
