View over the church
Month: October 2005
-
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. -
Yes! I did something for me!
TN Lottery Results is no longer terribly embarassing!
-
Of Grasshoppers
Student: Can we really learn from our mistakes?
Master: It would be a mistake to do otherwise. -
Rhys and liam sell popcorn for pack 251
Rhys and liam sell popcorn for pack 251
-
Noah and chase sell popcorn for pack 251
Noah and chase sell popcorn for pack 251
-
Come Buy Popcorn at Butler And Baileys!
Since nothing is better to snack on during football than popcorn Noah and I and some other scouts will be outside of Butler & Bailey (map) selling popcorn from noon to 4pm. The popcorns sales go on during October and are Pack 251’s only fundraiser. If you don’t want popcorn consider buying some as a Christmas gift or as a donation. Thank you!
-
Of Grasshoppers
Student: I grow shorter everyday.
Master: You carry too much weight. -
MS Events
Anyone going to any of the Microsoft MSDN or Launch events?
-
Programmer or Hack
There are days I just don’t feel like a programmer and then there are days like today! Wahoo! Let the code flow.
-
Thank G*d for David Bowie!
Thank G*d for David Bowie!
-
Why did Bush get re-elected?
Ariadne’s Labyrinth brings us a link to the reason (video with sound some foul language).
-
How are you doing?
I think perhaps the most cruel way to greet a person is to say "How are you doing?" No one really wants the real answer. They want the response "Fine thank you. And you?" What if you answered "well since you asked I’m not really doing so hot. I’m trying to be a hero to my kids and teach them right from wrong along with good manners but every time I turn around I’m be kidney punched and my self-confidence is shot. Seems like everytime I start to feel good about myself some smug sob comes along to yank the carpet out from under me. We are really lucky to be keeping food on the table. So, how’s things with you?"
Whenever someone I know is a psychologist or psychiatrist asks the "how are you?" question I grin and want to laugh because they don’t really mean it. So I respond "is that a personal or professional question?"
So I vowed to myself to work hard at removing "How are you?" type greetings from my vocabulary. Instead I choose to use more positive greetings such as "Good to see you!" or "You look great!" or even simply "Hello." Of course moments after I made this vow in my head I bumped into someone and I spouted out, "How you doing?"