Slide 11.17: WML variables, comments, and character entities
  Slide 11.19: WML selection (cont.)
  Home


WML Selection


A WML card can be set up to display the select and option functions of WML.




 

 http://people.cs.und.edu/~wenchen/cgi-bin/handheld/wml/Select.pl 

#!/usr/bin/perl

# Send the Content-type.
print "Content-type: text/vnd.wap.wml \n\n";

# Send the WML header information.
print "<?xml version=\"1.0\"?>\n";
print "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\""
   . " \"http://www.wapforum.org/DTD/wml_1.2.xml\">\n";

# Retrieve the Web argument values from the standard input.
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
  ($name, $value) = split(/=/, $pair);
  $value =~ tr/+/ /;
  $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  $value =~ s/~!/ ~!/g;
  $FORM{$name} = $value;
}

# Define a minimal deck.
$deck = "
<wml>
 <card title='Select Results'>
  <p><br/>
   You have selected:  <i>$FORM{cgi_items}</i><br/><br/>
  </p>
 </card>
</wml>";

# Send the deck.
print  $deck;