JavaScript Articles

iPhone Currency Input for Web Apps

I’ve been trying out a smaller JavaScript framework built exclusively for making web apps for mobile use names iWebkit. iWebkit makes it very easy for programmers to build a website that very closely resembles an iPhone App.

After using it for a few days I found myself wanting more functionality from it. Actually, if only two extra features were added to it I would love it so much more.

  • I need a black bottom navigation bar. A lot of iPhone apps use the area for main navigation. Apple’s native IPod app for example uses this area to navigate to
  • The other would be a currency input field. For example the input field starts off with 0.00 and when the user focuses on the input and starts entering in 1,2,3, the input would display, 0.01, 0.12, 1.23. I spoke with the developer via their forum and he confirmed that the functionality does not exist. So I took this on myself.

Since the black navigation bar would be a little more involved, I decided to add the currency input functionality myself. After all, I don’t have that much free time for fun little projects like this.

Below is the JavaScript function that I am calling for a currency input. I put it together pretty quickly so if anyone can think of anything to add to it to make it more complete, it would be greatly appreciated. I am using this code right now live and it appears to be working well.


//
// convertToFloat -
//
// param obj - This it the input box object
// param event - This is the keyboard input allowing us to detect what key was pressed based on the ascii code
// param decimal - The precision of decimal places I am rounding too
//
function convertToFloat(obj, event, decimal) {

var value = obj.value.replace(/[^0-9.]/g,'');
var ascii = event.which;
var convertedNum = parseFloat(value);

if (ascii == 8) { //backspace

if (value == 0) {
convertedNum = 0;
} else {
convertedNum = value/10;
}
// ascii codes between 48 and 57 are numbers
//don't react to other keyboard inputs
} else if (ascii >= 48 && ascii <= 57 && value < 1000000) {
convertedNum = value*10;
}

obj.value = convertedNum.toFixed(decimal);
return;
}


JavaScript – Create a Better Experience

If you’ve been surfing the net for a while, you must likely have encountered websites created using JavaScript.

JavaScript is a programming language used to develop dynamic websites which run at the client side. This means that the language will not execute at the server but will run with your web page on the browser of the user. It is often used to manage online advertisements, validation of forms, and check on the ID of the browser. It doesn’t conflict with other languages such as PHP or ASP when you design a website.
Features

This language has been in use for several years now to produce websites with nice effects. Here are some highlights of what it can do:

•Browser Integrated Support – You don’t have to install any plug-ins to view sites using JavaScript programming. Most of the web browsers support the language. You only have to handle some specific features of the browsers so it will run properly

Changing Structure Run time – Web pages can be modified during run time since it has access to Document Object Model. It can also be used from the server side for script changes to better manage web contents

•Functional – JavaScript can be assigned to a function or variable where each can return also as a function. This language doesn’t worry about tagging names to functions, as long as the programming is working, everything will just be fine

Object Oriented – This language is easy to learn and handles most programming objects with no conflict. Being a loose object oriented language make me love it!

Benefits of the JavaScript Language

The JavaScript websites are commonly designed to check for validating the inputs of users on an online form. Let say you have an order form on your website and a client forgets to fill up the fields for home address and postal code, the browser will prompt her to supply the needed information before continuing. This saves time instead of the process being checked by the server which handles a lot of data. ASP and PHP programming may also solve the problem but in a more time consuming way for the customer.

This programming language is also used to design vibrant web pages which may feature rolling over graphic components. This is also done from the side of the user through their web browser.

Other features like links and images can be manipulated using this scripting language. Other special effects for navigation can also be added to your website.

Sample Sites and Sample Script

Menu Bar Example – JavaScript was used in combination with HTML. The menu bar will be highlighted when you point the mouse to it. There will also be a drop down menu where each of the content will also be highlighted

Display Information as a Splash Screen – This is a great effect where information about your website or anything under the sun can be displayed on a splash screen.

Make a News Ticker – This allows you to tell web surfers that there are changes in your websites. The display will be text scrolling upward.

Help Users Navigate Your Site – a box will pop up when a user points her mouse to an item. It can be instruction, description, or reminders that you want to tell them.

JavaScript can be a great tool for designing exciting and functional websites. Just make sure that you maximize the features of this language so you can enhance the performance and appeal of your web pages.
Learning JavaScript, Shelley Powers, Excellent Book

US $5.74
End Date: Saturday Feb-04-2012 14:12:47 PST
Buy It Now for only: US $5.74
Buy it now | Add to watch list


JavaScript: The Good Parts

  • ISBN13: 9780596517748
  • Condition: NEW
  • Notes: Brand New from Publisher. No Remainder Mark.

Product Description
Most programming languages contain good and bad parts, but JavaScript has more than its share of the bad, having been developed and released in a hurry before it could be refined. This authoritative book scrapes away these bad features to reveal a subset of JavaScript that’s more reliable, readable, and maintainable than the language as a whole-a subset you can use to create truly extensible and efficient code.

Considered the JavaScript expert by many peopl… More >>

Price: $19.48
Rating: 4.0 (55 reviews)

JavaScript: The Good Parts
Here are a few auctions found on eBay:
Learning JavaScript, Shelley Powers, Excellent Book

US $5.74
End Date: Saturday Feb-04-2012 14:12:47 PST
Buy It Now for only: US $5.74
Buy it now | Add to watch list


  • BrownPHP Tag Cloud

  • Copyright © 1996-2010 Brown PHP. All rights reserved.
    iDream theme by Templates Next | Powered by WordPress

    Powered by Yahoo! Answers