Blog

  • Of Grasshoppers

    Student: I’m capable.
    Master: Then do.

  • Chat Away!

    For grins I added a chat application to TN Lottery Results. The same chat appears on Complete Lottery Info. I wonder if it will see any use.

  • World’s Smallest Controllable Robot

    "Researchers there have built what they say is the world’s smallest untethered, controllable robot. When placed on a penny, it looks like a mole on the side of Lincoln’s chin, measuring a hundredth of an inch by one four-hundredth of an inch."

  • Of Grasshoppers

    Student: How can I do more?
    Master: Say "no" a lot.

  • Going To be small lots

    Going To be small lots

  • In the end the will be no trees

    In the end the will be no trees

  • View over the church

    View over the church

  • This morning’s programming challenge

    Within the next 2 hours, write a piece of javascript that based upon values in a series of pulldowns determines the price of a product using quantity, an attribute, another attribute, a third attribute, and the size of the product. There is not a mathematical basis for the price.

    Update: The solution follows. This is viewable through the source otherwise I wouldn’t post it. Basically we create a class/object to hold the pricing data. When then create an array of objects to hold each permutation of pricing. Then we make a call to the database and fill the array. Finally, whenever a selection box is changed, we loop through the selections comparing values to what is stored in our objects until we find the one that has the price we want. Then we update the price field. The final product can be seen shortly at Marqiprinting.com under the products listings. Right now flyers works correctly and I’m updating code for the other products.


    //define a class to hold the data
    function productinfo(qty, coating, sides, tag, productsize, price) {
    //initialize object properties
        this.quantity = qty;
        this.uvcoating = coating;
        this.sides = sides;
        this.tag = tag;
        this.productsize = productsize;
        this.price = price;
    }

    //create an array to hold the objects of data
    var products = new Array();

    <?php
        $x=0;
        while($line=mysql_fetch_array($productsresourceid)){
           echo "products[".$x."] = new productinfo(".$line['Qty'].",".$line['Coating'].",".$line['NumSides'].",".$line['Tagline'].",'".$line['AvailableSize']."',".$line['ProductPrice'].");";
           $x++;
        }
    ?>

    function updateprice(){
        var pricefound = false;

        for(i=0; i < products.length; i++) {
           //test values here
           frm = document.productselection;
           //businescards = ProductSize, ProductSides, Coating, qty, tag
           //brochures = ProductSize, ProductSides, Coating, qty, tag
           //cdinserts = ProductSize, Coating, qty, tag, ProductSides
           //flyers = ProductSize, ProductSides, Coating, qty, tag
           //posters = ProductSize, ProductSides, Coating, qty, tag
          if(document.getElementById('ProductSize').options[document.getElementById('ProductSize').selectedIndex].value == products[i].productsize
              && document.getElementById('ProductSides').options[document.getElementById('ProductSides').selectedIndex].value == products[i].sides
              && document.getElementById('Coating').options[document.getElementById('Coating').selectedIndex].value == products[i].uvcoating
              && document.getElementById('qty').options[document.getElementById('qty').selectedIndex].value == products[i].quantity
              && document.getElementById('tag').options[document.getElementById('tag').selectedIndex].value == products[i].tag) {
          updatedivs('price','Price: $'+products[i].price.toFixed(2));
           pricefound = true;
           alert('price found! '+products[i].price);
           }
        }
        if(!pricefound)       updatedivs('price','Price: $----');
        }
    }

  • Interpret This

    I dreamed last night that I was trying to pull strings to get Matthew Perry a job. The dream was very fixated on the presidential bridge that connected Knoxville and Lenior City? (perhaps Chattanooga) so that the president could go from the one city to the other on a flat service without having to deal with driving through valleys and ridges.

  • Of Grasshoppers

    Student: I have a vice.
    Master: You have a vice squad.