"Murphy was an optimist!"
View over the church October 10, 2005 9:14 am
Posted by djuggler in : Daily LifeView over the church
add a commentThis morning’s programming challenge October 10, 2005 4:06 am
Posted by djuggler in : Daily LifeWithin 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 October 10, 2005 2:26 am
Posted by djuggler in : Daily LifeI 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.
add a commentOf Grasshoppers October 10, 2005 2:19 am
Posted by djuggler in : Daily LifeStudent: I have a vice.
Master: You have a vice squad.
Yes! I did something for me! October 9, 2005 12:00 pm
Posted by djuggler in : Daily LifeTN Lottery Results is no longer terribly embarassing!
add a commentOf Grasshoppers October 9, 2005 11:25 am
Posted by djuggler in : Daily LifeStudent: Can we really learn from our mistakes?
Master: It would be a mistake to do otherwise.
Rhys and liam sell popcorn for pack 251 October 8, 2005 3:20 pm
Posted by djuggler in : Daily LifeRhys and liam sell popcorn for pack 251
add a commentNoah and chase sell popcorn for pack 251 October 8, 2005 3:16 pm
Posted by djuggler in : Daily LifeNoah and chase sell popcorn for pack 251
add a commentCome Buy Popcorn at Butler And Baileys! October 8, 2005 9:40 am
Posted by djuggler in : Daily LifeSince 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!
add a commentOf Grasshoppers October 8, 2005 8:13 am
Posted by djuggler in : Daily LifeStudent: I grow shorter everyday.
Master: You carry too much weight.
MS Events October 7, 2005 1:51 pm
Posted by djuggler in : Daily LifeAnyone going to any of the Microsoft MSDN or Launch events?
add a commentProgrammer or Hack October 7, 2005 11:17 am
Posted by djuggler in : Daily LifeThere are days I just don’t feel like a programmer and then there are days like today! Wahoo! Let the code flow.
add a commentThank G*d for David Bowie! October 7, 2005 10:27 am
Posted by djuggler in : Daily LifeThank G*d for David Bowie!
add a commentWhy did Bush get re-elected? October 7, 2005 4:19 am
Posted by djuggler in : Daily LifeAriadne’s Labyrinth brings us a link to the reason (video with sound some foul language).
add a commentHow are you doing? October 7, 2005 4:00 am
Posted by djuggler in : Daily LifeI 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?"
add a comment