Amateur Needs Help With Drop Downs

Discussion in 'JavaScript' started by PaulSands, Jun 2, 2006.

  1. #1
    Hi everyone.
    I use Jalbum to generate gallery pages for my website and I have been trying to enhance it to allow selction of images sizes for purchase via PayPal by use of a drop down.
    Unfortunately it only partially works and I cant get my head around whats wrong . The PayPal shopping basket is populated with the correct quantity and £ value but no item description is being included. I wish for the description to be a combination of the image date, venue & meeting, that come through as parameters, plus the file name.
    I've posted the code used to build the slide page in JAlbum beloiw. If thats not the correct thing to do please let me know and I'll get it removed

    <head>
    <meta http-equiv="content-type" content="text/html;
    charset=$textEncoding" />
    <title>photo-kinesis imaging $label</title>

    <script language="javascript">
    showing = false;

    function toggleInfo() {
    if (showing == false) {
    if (document.all || document.getElementById)
    document.getElementById('imageinfo').style.visibility="visible"; // IE
    & Gecko
    else document.layers['imageinfo'].visibility="show"; // Netscape 4
    showing = true;
    }
    else {
    if (document.all || document.getElementById)
    document.getElementById('imageinfo').style.visibility="hidden"; // IE &
    Gecko
    else document.layers['imageinfo'].visibility="hide"; // Netscape 4
    showing = false;
    }
    }
    </script>

    </head>

    <body id="slide" BGCOLOR= "black">


    <table width="100%">
    <tr class="head">
    <td class="number" width="30%">$imageNum/$totalImages</td>
    <td class="date" width="20%"></td>
    <td class="name">$label</td>

    <td class="navigation" width="20%">

    <!-- Home -->
    <a href="/index.htm"><img src="$resPath/home.gif" border=0
    alt="back to photo-kinesis">
    <!-- Index button -->
    <a href="../$indexPage"><img src="$resPath/index.gif" border=0
    alt="$text.indexPage"></a>

    <!-- Previous button -->
    <ja:if exists="previousPage">
    <a href="$previousPage"><img src="$resPath/previous.gif"
    alt="$text.previousPage" border=0></a>
    </ja:if>
    <ja:else>
    <img src="$resPath/previous_disabled.gif" alt="$text.atFirstPage">
    </ja:else>

    <!-- Next button -->
    <ja:if exists="nextPage">
    <a href="$nextPage"><img src="$resPath/next.gif" alt="$text.nextPage"
    border=0></a>
    </ja:if>
    <ja:else>
    <img src="$resPath/next_disabled.gif" alt="$text.atLastPage">
    </ja:else>

    </td>
    </tr>

    </table>
    <center>

    <table><tr valign="TOP"><td>

    <!-- Image, maybe with link to original -->
    <ja:if exists=originalPath>
    <a href="$originalPath">
    <img src="$imagePath" width="$imageWidth" height="$imageHeight"
    border=0 alt="$text.originalImage">
    </a>
    </ja:if>
    <ja:else>
    <img src="$imagePath" width="$imageWidth" height="$imageHeight">
    </ja:else>

    <!-- Always display comment below image (if exists) -->


    <ja:if exists="comment">
    <br>
    <div class="name">$comment</div>
    </ja:if>
    <ja:else>
    <!-- Try to extract the comment from a file carrying the same base
    name as this image -->
    <br>
    <div class="name">
    <ja:include page="<%= new File(imageDirectory, label+".txt") %>" />
    </div>
    </ja:else>
    <br>


    <p>
    <font face="arial" color="white" size="2">
    album created with <a href="$generatorUrl"
    target="_blank">$generator</a></font>


    </td>
    <td>
    <p>
    <p>

    <!--
    <a href="mailto:info@photokinesis.co.uk?subject=photo-kinesis image info request
    for $meet $venue $meetdate $imagePath
    &body=Please provide information about the above
    image"><img src="http://www.paulsands.org/mail.jpg" border="0" alt="request more info"></a><b><font face="arial" color="white" size="3">Click email icon to request<br>information
    regarding image</font></b> -->





    <script language="JavaScript" type="text/JavaScript">


    function add_item_to_order(image, name, price, qty)
    {
    var s;

    if (qty > 0) {
    s = "&item_name=" + " - " + name + "&quantity=" + qty + "&amount=" + price;
    }

    return s;
    }

    function add_to_basket()
    {
    var str = "https://www.paypal.com/cgi-bin/webscr?cmd=_cart&business=psands62@yahoo.com&info&add=1&no_note=1&currency_code=GBP&lc=GBP";
    var buy_str = "";
    var image_name = window.document.order.image.value;
    var choice = window.document.order.choosesize.value;
    var qty = window.document.order.qty.value;
    var win_options = "menubar,location,toolbar,status,directories,resizable,scrollbars";

    switch (choice) {
    case "1":
    buy_str = add_item_to_order(image_name, "6\" x 4\" Print", 6, qty);
    break;
    case "2":
    buy_str = add_item_to_order(image_name, "7\" x 5\" Print", 8, qty);
    break;
    case "3":
    buy_str = add_item_to_order(image_name, "9\" x 6\" Print", 10, qty);
    break;
    case "4":
    buy_str = add_item_to_order(image_name, "A4 Print", 12, qty);
    break;
    case "5":
    buy_str = add_item_to_order(image_name, "18\" x 12\" Print", 20, qty);
    break;
    case "6":
    buy_str = add_item_to_order(image_name, "20\" x 16\" Print", 25, qty);
    break;
    case "7":
    buy_str = add_item_to_order(image_name, "900 x 600 Digital Image", 12, qty);
    break;
    case "8":
    buy_str = add_item_to_order(image_name, "3000 x 2000 Digital Image", 20, qty);
    break;
    case "9":
    buy_str = add_item_to_order(image_name, "Photo Mouse Mat", 15, qty);
    break;
    case "10":
    buy_str = add_item_to_order(image_name, "Photo Mug", 15, qty);
    break;
    }


    str += buy_str;

    if (buy_str) {
    window.open (str, "", win_options);
    }
    //alert(str);
    }

    function view_basket()
    {
    var str = "https://www.paypal.com/cgi-bin/webscr?cmd=_cart&business=psands62@yahoo.com&info&submit&display=1";
    var win_options = "menubar,location,toolbar,status,directories,resizable,scrollbars";

    // alert('str = ' + str);
    window.open (str, "", win_options);
    }

    </script>
    <form action="" method="post" name="order" id="order">
    <table align="center" border="0" width="249">
    <tbody><tr>
    <td width="156"><div align="right"><strong><font face="Arial, Helvetica, sans-serif" size="2">Select
    Print/Image Size</font></strong></div></td>
    <td width="26">&nbsp;</td>
    <td width="53"><strong><font face="Arial, Helvetica, sans-serif" size="2">Quantity</font></strong></td>
    </tr>
    <tr>
    <td><div align="right">
    <select name="choosesize" id="choosesize">
    <option value="1" selected="selected">6" x 4" Print - £6</option>
    <option value="2">7" x 5" Print - £8</option>
    <option value="3">9" x 6" Print - £10</option>
    <option value="4">A4 Print - £12</option>
    <option value="5">18" x 12" Print - £20</option>
    <option value="6">20" x 16" Print - £25</option>
    <option value="7">900 x 600 Image - £12</option>
    <option value="8">3000 x 2000 Image - £20</option>
    <option value="9">Photo Mouse Mat - £15</option>
    <option value="10">Photo Mug - £15</option>
    </select>
    </div></td>
    <td>&nbsp;</td>
    <td><font face="Arial, Helvetica, sans-serif" size="2">
    <select name="qty" id="select7">
    <option value="0">0</option>
    <option value="1" selected="selected">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    </select>
    </font></td>
    </tr>
    <tr>
    <td height="22">
    <div align="right"> </div></td>
    <td colspan="2"><div align="left"> </div></td>
    </tr>
    </tbody></table>

    <table align="center" border="0" width="300">
    <tbody><tr>
    <td><div align="right">
    <input name="image" id="image6" value=""$meet $venue $imagePath $meetdate"" type="hidden">
    <input name="add2" id="add22" value="Add To Basket" onclick="add_to_basket()" type="button">
    </div></td>
    <td><input name="view2" id="view22" value="View Basket" onclick="view_basket()" type="button"></td>
    </tr>
    </tbody></table>
    </form>


    </td>

    </td>


    </table>

    </center>
    </body>
     
    PaulSands, Jun 2, 2006 IP