A little monkey snooping

Careerbuilder.com has a new website out there (er, it’s probably been out for awhile) that allows you to send people “monk-e-mails” — customizing a monkey with some various audio capabilities, including text-to-speech.

Of course the messages are not private (Careerbuilder says so), so any snooping with the ID value gives you other messages people threw together.

To make my poking around a bit more productive (without having to type in ID numbers), I put together a little page that does the magic for me. Introducing: MonkeySnoop!

Digg This
October 25, 2007, 2:51 pm

Using JavaScript to get radio values

A coworker was trying to figure out how to use JavaScript to get a RADIO value from a form. Because a radio form element makes up an array of possible selections, you have to cycle through that array to find the selected value. It is then that you can retrieve the actual selected value.

Check out the code below that I’m using to get the value of the selected radio element. From this you should be able to customize it for your needs. Simply insert your code or run your function in the level where I’m running the alert() command.

<script language="javascript">
function rockmyworld() {
 i=0;
 do {
  if (form.myRadio[i].checked == true) {
   alert(form.myRadio[i].value);
  }
  i++;
 } while (i < form.myRadio.length);
}
</script>
<form name=”form”>
<input type=”radio” name=”myRadio” value=”1″/> 1 <br/>
<input type=”radio” name=”myRadio” value=”2″/> 2 <br/>
<input type=”radio” name=”myRadio” value=”3″/> 3 <br/>
<input type=”button” value=”get value” onClick=”rockmyworld()”/>
</form>

Hope that helps any folk out there that were burnin’ brain cells trying to figure this out.

Digg This
March 31, 2006, 3:27 pm

IE bug with stylesheets and javascript?

So I’ve been working on one of our intranet sites and it looks just fine when I view it independently. Unfortunately though, we have everything in a frames environment…so when I view the site in the frames, the copy gets all tripped out, stacking upon itself when I scroll and/or navigate to other pages within that site.

I know it’s a stylesheet issue, for when I remove the stylesheet the problem goes away. But the thing I can’t figure out is why it’s doing it, when all the styles are W3C compliant and aren’t doing much other than setting padding values, font sizes, a few background elements. Pretty basic stuff.

Check it out for yourself: Before & After

I’m pretty much losing my mind trying to figure this out, since there’s another site that uses the SAME CODE (just located on a different server) and works just fine. Go figure.

Any thoughts anyone out there in the web development community?


UPDATE

For starters…this DOES work properly in Firefox. That wasn’t a suprise. But if you look at the example images, I’ve got a white then gray stripe down the left side. The image basically stops at the end of the gray stripe and I have it repeating vertically (Y axis) and have the following code in the body { } style:
background-image: url("../images/side_graystripe.gif");
background-repeat:repeat-y;

So I tried removing that snippet and everything worked fine. My solution? Take that background .gif image and extended it to 1600 px wide (the max width it’d be viewable at) and left the code in the stylesheet.

IE is apparently freezing the content when you scroll or nav to other pages with that same background code. Can we say “BUG?”

It’s an unusual scenario, I know, but at least I figured it out. Hope this helps anyone out there running into the same issue.

Digg This
March 23, 2006, 4:04 pm

How does your salary stack up?

Down right depressing compared to the likes of David Letterman, Keanu Reeves, Harrison Ford, etc. when you use salary.com’s salary timer. It’s a clever (but useless) JavaScript that compares your annual salary against an array of celebrities and then does a calculation (every second, on the second) updating your real-time salary.

I’ve had mine running up against David Letterman now for a little over an hour and he’s made $17, 800.00+ and counting — humbling what I make by comparison.

For a little extra bonus, click the Burg-O-Meter to calculate your earnings in burgers and other material goods. Just within this short sentence, David has already made over a hundred Big Macs and I don’t think I’ve even made one bite’s worth.

Isn’t that uplifting!?

Digg This
January 27, 2006, 11:48 am

Image Mouseover Javascript: Stripped Down

Javascript mouseover function has been around for at least eight years now, from somewhere around 1996/7 on. I see a lot of sites (including some of my own) that use Javascript for mouseover functions and decided to try and strip out as much code as I could to try and reduce the redundancy and unnecessary code used to perform such a simple procedure… swapping out an image for another one. Dreamweaver (as an example) is notorious for producing more code than you need.

Be sure to follow the instructions in the iFrame below:

Digg This
November 28, 2005, 1:51 pm

Select Fields & Div Tags—Simplified

A co-worker was having problems getting a JavaScript to work, attempting to reveal a given hidden div tag based on a select field form selection. He was going about it in a more complicated manner, and I stepped in and offered a much more simplified approach to revealing a div tag based on a form selection.

First, the source code:

<script language="javascript">
<!–
function showField(hiddenField) {
var swapWithThis = document.getElementById(hiddenField).innerHTML;
document.getElementById(”targetField”).innerHTML = swapWithThis;
}
//–>
</script>
<form action=”">
<select id=”selectField” onChange=”showField(this.value);”>
<option value=”">select an option</option>
<option value=”divOne”>Show div one</option>
<option value=”divTwo”>Show div two</option>
<option value=”divThree”>Show div three</option>
</select>
</form>
<div id=”targetField”></div>
<div id=”divOne” style=”display: none;”>This is Div 1</div>
<div id=”divTwo” style=”display: none;”>This is Div 2</div>
<div id=”divThree” style=”display: none;”>This is Div 3</div>

In this example, we’ve got some hidden div tags with content and a select field with values that correspond with the given hidden div tags. We’re simply running a function I created called “showField” with every onChange event that occurs with that form field. On that event, we’re sending the value (this.value) of the selection field “selectField” to the function. The function then grabs the innerHTML (all that is contained within the DIV tag—HTML included) of the corresponding div tag—that is, the div tag that has an ID value that matches the selection value.

We then take that innerHTML and slap it into the blank target div tag (id=”targetField”). It’s really simple, actually, and works like a charm. Test the demo here.

Parting Thought…

If you’re using this method to reveal more select fields or modify values in other target form fields, it would be wise to make use of a target HIDDEN form field to capture the final data value that you’re after. Why? Depending upon how you’re using this, you might run the risk of losing your form data/attributes in those hidden/revealed states. What I suggest is having hidden form elements to receive the final selection values—this way they remain unaffected by the selection event.

UPDATE 4/19/2006: When I originally posted this entry, I had “visiblity: none;” as the attribute in the DIV tags. The PROPER attribute is to have “display: none;” instead. This will ensure that nothing in that layer displays whatsoever.

Digg This
August 23, 2005, 2:25 pm

HVMenu Frames Issue/Fix

With a project I’ve been working on, I’ve been using a great DHTML script called HVMenu found at Dynamic Drive. If you’re using it for a regularly formatted site (i.e. no frames) it works GREAT. But once you introduce frames (at least with the version on DD), it gets a bit ugly—specifically when you’re also linking to pages outside your domain and HAVE to keep that page within your site.

When you’re trying to do that, HVMenu version 5.whatever breaks and has a hissy fit. The menu fly-out doesn’t occur and if you try to force a refresh event in the javascript file, the menu doesn’t show up. You actually have to physically reload the page with the reload/refresh button. Unacceptable.

(more…)

Digg This
August 3, 2005, 2:17 pm

Dynamic Stock Information

I’ve been looking for options for a stock ticker for an intranet page we’re developing here and the current feed that’s available to us right now is very limiting—we’re basically forced to accept a feed with certain dimensions, color scheme and a nasty “logo” to boot.

So my first reaction… “AGH, there’s gotta be someone out there doing an XML/RSS type of stock info feed out there”.

I found a posting on someone’s blog about how they’ve developed an XML result by simply querying Yahoo. While the gentleman didn’t share his code with the world, I thought I would at least share the URL string to use when querying Yahoo. Insert the ticker symbol where it’s noted in bold:

http://finance.yahoo.com/d/quotes.csv?s=UNH&f=sl1d1t1c1ohgv&e=.csv

With the above example, here is what is contained in the .csv file that it dynamically gives me:

“UNH”,51.87,”7/12/2005″,”2:40pm”,-0.56,52.53,52.90,51.75,4787200

a simple comma-delimited file with important stock information. It provides (in this order) symbol, last trade amount, day of last trade, time of last trade, change (plus or minus), opening value, day’s high, day’s low, and what I presume to be volume.

My next goal is to see how I can take that information and make my own xml file and/or parse it with flash to create a stock ticker that’s a bit more flexible to work with.

Anyway, thought I’d pass on that tidbit of information.

Digg This
July 12, 2005, 3:00 pm

The World of AJAX

Okay… now I’m starting to tread into dangerous development waters… Isaac piqued my curiosity in what’s beed dubbed AJAX. AJAX stands for Asynchronous JavaScript and XML, a term describing a web development technique for creating interactive web applications, combining the power of XML, JavaScript, and HTML/XHTML/CSS, along with your run-of-the-mill server-side scripting like PHP or ASP.

I found an okay primer on using XMLHttpRequest, but it made quite a few assumptions and didn’t provide enough explanations as to what was what and why they did it or why it worked.

Anyone have any great intro/primer web resources out there on AJAX and related XMLHttpRequest resources? I’ve decided that this is a new frontier that I’d like to venture off into and become more in tune with.

Related Links:
A Simpler AJAX Path


Digg This
July 8, 2005, 9:54 am

URL Strings Handled by JavaScript & Flash

One of the challenges that I face in my Flash development is the handling of dynamic choices in data selection in a not-so-dynamic environment. Because usage and access to databases and dynamic scripting requires an act of congress, I am left with the necessity of improvisation and taking advantage of as many client-side abilities as I can.

Challenge: I’ve got an XML file with an array of choices that the user can choose from. They’re basically flash-based marketing modules—animations with voice-overs about our various services and options. Each user, employee, or employer can choose which modules they want to view and that means that there could be hundreds of thousands of possible combinations of modules that people can view and in the order that they want.

Limitations: A static XML file containing data about the flash modules, HTML, JavaScript,

(more…)

Digg This
June 20, 2005, 9:46 am