In the last article, I discussed Wireless Markup Language (WML) and built an introductory page for my WML company directory. Now I'm going to create the Active Server Pages (ASP) that will create the resulting WML for finding phone numbers.

The ASP page takes the form input from the mobile device and uses that information to provide a list of results from the search. However, for the location and department searches, a list of locations and departments are provided if one hasn't already been selected.

I'm using a Microsoft Access database as the underlying data. Here's the code to take the search criteria and create the output necessary:

First, this page sets the Content-type of the response to "text/vnd.wap.wml", which is the MIME-type that mobile devices (and WAP gateways) understand. Then, I open a connection to the database through ADO. I create a couple of local variables to hold my query type (qt) and query value (qv) form values. Then, I write out the top portion of the WML page to the Response buffer.

In the next bunch of VBScript, I check the query type for the appropriate action. If the query type is "loc" for location, I check the query value variable to see if it's set. If the query type isn't "loc", I return a list from which the user will select a location. Then I do the same thing for "dpt" or department.

When the user enters the query type and query value, I create a list of anchors from the names in the data; this is also true for last name and first name search. Because of the limitations of WAP and WML, I restrict my output to five names. If there are more than five names in the result set, I pass another anchor that says "More. . .". This anchor also provides the last identity column from the underlying data. This information is used to supply the next group of results from the query.

When the user selects the name anchor, they're sent to the final page that displays the information on the selected name. Here's the code that accomplishes this:

This code looks into the underlying data to find the person that matches the identity column data (tblPhone.phone_id). The result is a line that displays the person's name, a line for the phone number, a line for the department, and a line for the location. I also provide the phone number in an <input> element, so when the user focuses on this field, the user's phone may give them the option to use that number.

When you provide your output as the result of a scripting language such as ASP, you need to set the Content-type on the result; this lets the WAP gateway know that it's dealing with WML data. Also, keep your information to a minimum, since phones' resources may be limited.

In order to create this code and test it without incurring severe cell phone charges, I used the downloadable Nokia Mobile Internet Toolkit (which is listed under the Content Authoring heading).

Phillip Perkins is a contractor with Ajilon Consulting. His experience ranges from machine control and client server to corporate intranet applications.

Do you need help with Embedded/Mobile? Gain advice from Builder AU forums

Related links

Leave a comment

You must read and type the 6 chars within 0..9 and A..F

* indicates mandatory fields.

Log in


Sign up | Forgot your password?

  • Staff Aussies to pay more for Win 7

    If you are looking to make some money in these troubled times, perhaps importing copies of Windows 7 could be for you. Read more »

    -- posted by Staff

  • Staff Firefox: Greens want it, 3.5rc2 not up to par

    This week's roundup looks at the situation surrounding a campaign to change Outlook HTML renderer, a Greens MP wants to install Firefox but is restricted and all the photos from the iPhone 3GS launch. Read more »

    -- posted by Staff

  • Chris Duckett Microsoft misses the Outlook point

    Ask designers which mail program is the bane of their existence, and you'll find that Outlook tops the list. The reason why the most popular email reader is also the most painful is simple: it uses Word to render HTML emails. Read more »

    -- posted by Chris Duckett

What's on?