1 DIG 3134 Lecture 9. Dynamic HTML Controls Michael Moshell University of Central Florida Media Software Design.

Slides:



Advertisements
Similar presentations
Question Bank. Explain the syntax of if else statement? Define Union Define global and local variables with example Concept of recursion with example.
Advertisements

UFCE8V-20-3 Information Systems Development 3 (SHAPE HK) Lecture 3 PHP (2) : Functions, User Defined Functions & Environment Variables.
DLC-MODS Workbook 1.2 Pinky says, “Hello.” Presented by University of Tennessee Libraries Digital Library Center Melanie Feltner-Reichert, Metadata Librarian.
Intermediate Level Course. Text Format The text styles, bold, italics, underlining, superscript and subscript, can be easily added to selected text. Text.
Microsoft Excel 2010 Chapter 7
1 HTML Markup language – coded text is converted into formatted text by a web browser. Big chart on pg. 16—39. Tags usually come in pairs like – data Some.
Jonathan Voigt University of Michigan Soar Workshop 25
CGI Programming in Perl Software Tools. Lecture 22 / Slide 2 CGI Programming l Last time we looked at designing a static web page. Today we will see how.
CGI programming in Perl Learning Objectives: 1. To understand how a CGI program works in Perl and how to make it runnable in web browsers 2. To learn how.
3D Game Programming All in One By Kenneth C. Finney.
There is a certain way that an HTML file should be set up. The HTML section declares a beginning and an ending. Within the HTML, there should be a HEAD.
Guide To UNIX Using Linux Third Edition
Introduction to scripting
® IBM Software Group © 2006 IBM Corporation JSF Tab Controls This Learning Module shows how to develop server-side EGL applications with dynamic content.
1 DIG 3134 – Lecture 3 Forms Michael Moshell University of Central Florida Media Software Design.
WinTR-20 Project Formulation Hydrology Computer Program Basic Input and Output Presented by: WinTR-20 Development Team.
WinTR-20 Project Formulation Hydrology Computer Program Basic Input and Output Presented by: WinTR-20 Development Team.
JAVASCRIPT HOW TO PROGRAM -2 DR. JOHN P. ABRAHAM UTPA.
M-files While commands can be entered directly to the command window, MATLAB also allows you to put commands in text files called M- files. M-files are.
INTRO TO PROGRAMMING Chapter 2. M-files While commands can be entered directly to the command window, MATLAB also allows you to put commands in text files.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
Lecture 6 – Form processing (Part 1) SFDV3011 – Advanced Web Development 1.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)PHP Recap.
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Ch 11: Userforms CP212 Winter Topics Designing User Forms o Controls Setting Properties o Tab Order o Testing Writing Event Handlers o Userform_Initialize.
Chapter 6 Generating Form Letters, Mailing Labels, and a Directory
REVIEW 2 Exam History of Computers 1. CPU stands for _______________________. a. Counter productive units b. Central processing unit c. Copper.
PMS /134/182 HEX 0886B6 PMS /39/80 HEX 5E2750 PMS /168/180 HEX 00A8B4 PMS /190/40 HEX 66CC33 By Adrian Gardener Date 9 July 2012.
Internet and Distributed Representation of Agent Based Model by- Manish Sharma.
HOWTO : Text-Out Function. Connections Link RS-485 Lines –Link DVR 485 Lines with Camera’s RS-485 Port.
Introduction To Microsoft Word C Apply intermediate skills in utilizing word processing software Word processing programs make the writing process.
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
Chapter 2 - More Controls More controls – Text boxes - used for user input – Frames - containers to group items – check boxes - user select an option -
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Copyright 2007, Information Builders. Slide 1 Enhancing Maintain Applications with HTML Mark Derwin and Mark Rawls Information Builders.
Linux+ Guide to Linux Certification, Third Edition
1 DIG 3134 – Lecture 11: Two Dimensional Arrays And Dynamic Controls AND CONSTANTS Michael Moshell University of Central Florida Internet Software Design.
PHP - Basic Language Constructs CSCI 297 Scripting Languages - Day Two.
Page 1 Non-Payroll Cost Transfer Enhancements Last update January 24, 2008 What are the some of the new enhancements of the Non-Payroll Cost Transfer?
Working with Files. Learning Objectives By the end of this lecture, you should be able to: – Examine a file that contains code with unfamiliar material,
1 DIG 3134 Lecture 5: Functions Michael Moshell University of Central Florida Media Software Design.
Guide to Oracle 10g ITBIS373 Database Development Lecture 4a - Chapter 4: Using SQL Queries to Insert, Update, Delete, and View Data.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
Counter-Controlled Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
1 DIG 3134 – Lecture 4: Arrays and Strings Michael Moshell University of Central Florida Media Software Design.
Practical Programming COMP153-08S Week 5 Lecture 1: Screen Design Subroutines and Functions.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
MATLAB for Engineers, by Holly Moore. ISBN © 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is.
Session 2: Basic HTML HTML Coding Spring 2009 The LIS Web Team Presents.
ITERATION. Iteration Computers are often used to automate repetitive tasks. Repeating identical or similar tasks without making errors is something that.
ENG College of Engineering Engineering Education Innovation Center 1 Functions 1 in MATLAB Topics Covered: 1.Uses of Functions Organizational Tool.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
Form Data (part 2) MIS 3502, Fall 2015 Brad N Greenwood, PhD Department of MIS Fox School of Business Temple University 11/10/2015 Slide 1.
1 DIG 3134 Lecture 8: Reading and Writing Text Files Michael Moshell University of Central Florida Media Software Design.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
Chapter 7 Creating Templates, Importing Data, and Working with SmartArt, Images, and Screen Shots Microsoft Excel 2013.
Chapter 6 Functions The Tic-Tac-Toe Game. Chapter Content In this chapter you will learn to do the following: 0 Write your own functions 0 Accept values.
Creating a script create new blank document. Editor options Docking and undocking tabs.
Analyzing Data Module 4.
Arrays: Checkboxes and Textareas
Arrays and files BIS1523 – Lecture 15.
Scripts & Functions Scripts and functions are contained in .m-files
Python I/O.
In Class Program: Today in History
Video list editor BIS1523 – Lecture 24.
Text Analyzer BIS1523 – Lecture 14.
Functions Christopher Harrison | Content Developer
Presentation transcript:

1 DIG 3134 Lecture 9. Dynamic HTML Controls Michael Moshell University of Central Florida Media Software Design

2 The Objectives: Learn how to create controls based on the contents of a data file Learn how to accept and process commands through that interface.

Our Design Task: Pundex Our goal: build a system that provides an onscreen list of puns. The user selects one (by radio button) and that pun description and corresponding image are shown on the screen. The entire system should be table-driven. That is, everything about the display should come from a set of text files and image files – NOT from any limits built into the software. Kornegay.net Somethingpunny.tumbir.com

Our Design Task: Pundex Here's a file that we want to use for our AutoPun System: pundex.txt KeyphraseDescriptionImage file I blew itflutemistake.txtfluteplayer.jpg Tune a fishtunafish.txttuna.jpg Catastrophecatasstrophy.txtcatastrophe.jpg Etc … The output should include a title, a text and a picture for the selected pun. Fulltimewow.blogspot.com Kornegay.net Studentoftheworld.info Somethingpunny.tumbir.com

Our standard design process Inputs: The pundex file which lists the puns, texts, images. A directory containing text files that explain the puns A directory containing image files to illustrate the puns. A set of radio buttons on Screen 1 to select the pun. Outputs: Screen 1: display list of pun titles, radio buttons, GO button. Screen 2: display the pun, show a CONTINUE button. Functionality: If no input or "CONTINUE", display screen 1. If GO, use the number from radio button to select a pun. State: None. We will reload the pundex from file at every cycle. Fulltimewow.blogspot.com

Step 1: Build a text-reading function #textloader: function textloader($whatfile) { if (!file_exists($whatfile)) { print "Sorry, can't find $whatfile."; exit; } else { $textarray=file($whatfile); return $textarray; } }# textloader EXAM ALERT: Look up and UNDERSTAND Each of the Green built-in functions

A more detailed way to read a file #textloader2: function textloader($whatfile) { $thefile = fopen($whatfile, "r"); $i=1; while (!feof($theFile)) { $textarray[$i] = fgets($theFile); $i++; } fclose($theFile); return $textarray;}# textloader } EXAM ALERT: Look up and UNDERSTAND Each of the Green built-in functions

A more detailed way to read a file #textloader2: function textloader($whatfile) { $thefile = fopen($whatfile, "r"); $i=1; while (!feof($theFile)) { $textarray[$i] = fgets($theFile); $i++; } fclose($theFile); return $textarray;}# textloader } Why am I showing you a complex approach when good old file() is simpler? Because you need to READ code as well as write it.

The pundex.txt file: KeyphraseDescriptionImage File I blew itflutemistake.txtfluteplayer.jpg Tune a fishtunafish.txttuna.jpg Catastrophecatasstrophy.txtcatastrophe.jpg Internally, it is actually represented like this ("tab delimited text") Keyphrase\t Description\t Image File I blew it\t flutemistake.txt\t fluteplayer.jpg Tune a fish\t tunafish.txt\t tuna.jpg Catastrophe\t catasstrophy.txt\t catastrophe.jpg \t is the TAB character. It is invisible when printed.

10 Step 2: Build a display function function displayPunTable($pundex) {print " "; $row=0; foreach ($pundex as $punline) {$punitems=explode("\t",$punline); // The items in the puntable are separated by tabs if (!empty($punitems[0])) { if ($row>0) $buttonitem="<input type='radio' name='punselect' value=$row>"; else $buttonitem=' '; print " $buttonitem ". $punitems[0]." "; $row++; } } print " "; } #displayPunTable

11 Step 2: Build a display function function displayPunTable($pundex) {print " "; $row=0; foreach ($pundex as $punline) {$punitems=explode("\t",$punline); // The items in the puntable are separated by tabs if (!empty($punitems[0])) { if ($row>0) $buttonitem="<input type='radio' name='punselect' value=$row>"; else $buttonitem=' '; print " $buttonitem ". $punitems[0]." "; $row++; } } print " "; } #displayPunTable

12 Step 2: Strings and Arrays $punline looks like this: "I blew it\tflutemistake.txt\tfluteplayer.jpg" $punitems=explode("\t",$punline); $punitems looks like this after the 'explode' function does its work: $punitems[0] ="I blew it"; $punitems[1]="flutemistake.txt"; $punitems[2]="fluteplayer.jpg";

13 Step 2: Build a display function function displayPunTable($pundex) {print " "; $row=0; foreach ($pundex as $punline) {$punitems=explode("\t",$punline); // The items in the puntable are separated by tabs if (!empty($punitems[0])) { if ($row>0) $buttonitem="<input type='radio' name='punselect' value=$row>"; else $buttonitem=' '; print " $buttonitem ". $punitems[0]." "; $row++; } } print " "; } #displayPunTable

14 Step 2: Build a display function In the HTML that is generated, if we 'view source' we will see: Keyphrase I blew it Tune a fish Catastrophe The resulting screen looks like this:

15 Get that much working. Then … We now need code to PROCESS these radio buttons. Examine the else if ($act=="GO") case in punshow.php We see another explode, to break up the $Pundex table. But now It's inside a foreach loop. So we now have arrays inside an array! $puninfo[0] = array ('Keyphrase', 'Description', 'Image File'); $puninfo[1]= array ('I blew it', 'flutemistake.txt', 'fluteplayer.jpg'); etc $punselect=$_POST['punselect']; // gets the Radio Button data. $mypun=$puninfo[$punselect]; // so, if $punselect was 1, we have This result: $mypun[0]='I blew it'; $mypun[1]='flutemistake.txt'; $mypun[2]=…

16 And the result is … Examine the code Demonstrate the program Edit the configuration files and run it again.

17 A diagnostic tool: "logprint" $Testnumber=3; // at the top of the program, easy to find and change function logprint($what, $when) { global $Testnumber; if ($Testnumber==$when) print "LP: $what "; } # logprint Then, in the code, if you want to see the value of variables X and Y: logprint("x=$x, y=$y",3); // and the output will be LP: x=3 Then to turn off the test-prints, after the problem is solved: $Testnumber=4;

18 One last trick: "implode" Explode transformed a string into an array (Each cell contained a part of the string, broken at the \t characters) But what does implode do? Just the opposite! Array into string. If $ardata[0]="dog"; and $ardata[1]="cat" and $ardata[2]="snake", $string=implode('K ',$ardata); Then $string="dogKcatKsnake"; The template for the implode function looks like this: string implode([string $glue,] array $pieces) these square brackets mean 'optional parameter'.

19 One last trick: "implode" string implode([string $glue,] array $pieces) these square brackets mean 'optional parameter'. This is unusual because normally optional parameters come LAST not FIRST. So I looked it up. "For historical reasons, implode accepts its arguments in either order." (So it must recognize them by data type, looking for an array and a string.) If there is no string, then no glue character is used. The array's rows are concatenated with no separators.