473,241 Members | 1,513 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

This class returns HTML content but fails in producing globals, why?

The following class is supposed to produce a series of HTML dropdowns
and HTML text fields based solely upon variable names for month, day
and year passed into it. Those variable names will correspond to
actual variables with values that are passed into the preSelect()
function inside the methods (that function is called from an outside
parent script included). However, upon careful inspection the global
function does not globalize anything within any method.

Can someone look at this and tell me what I did wrong?

Thanx
Phil

// USE THIS CLASS TO GENERATE A SERIES OF DROPDOWNS AND TEXT FIELDS
PERTAINING TO MONTH / DAY / YEAR
class DropdownGenerator {
var $hasMonth, $hasDay, $hasYear,
$monthVar, $dayVar, $yearVar,
$yearFieldLength,
$monthArray;

function DropdownGenerator($monthVar = '', $dayVar = '', $yearVar =
'', $yearFieldLength = 4) {

$this->yearFieldLength = $yearFieldLength;
foreach (array('month', 'day', 'year') as $key => $val) {
$this->{$val . 'Var'} = ${$val . 'Var'};
$this->{'has' . ucfirst($val)} = (strlen($this->{$val . 'Var'}) >
0) ? 1 : 0;
if (strlen($this->{$val . 'Var'}) > 0) global ${$this->{$val .
'Var'}};
}

$this->monthArray = array('01' => 'January',
'02' => 'February',
'03' => 'March',
'04' => 'April',
'05' => 'May',
'06' => 'June',
'07' => 'July',
'08' => 'August',
'09' => 'September',
'10' => 'October',
'11' => 'November',
'12' => 'December'
);

}

function getMonthDropdown() { // STRING "METHOD" TO PRODUCE MONTH
DROPDOWN
global ${$this->monthVar};

if (!$this->hasMonth) return '';
$html = $this->monthVar . ' = ' . ${$this->monthVar} . '<select
size="1" name="' . $this->monthVar . '">';
foreach ($this->monthArray as $key => $val)
$html .= '<option value="' . $key . '"' .
preSelect(${$this->monthVar}, $key) . '>' . $key . ' - ' . $val .
'</option>';
$html .= '</select>';
return $html;
}

function getDayDropdown() { // STRING "METHOD" TO PRODUCE DAY
DROPDOWN
global ${$this->dayVar};

if (!$this->hasDay) return '';
$html = '<select size="1" name="' . $this->dayVar . '">';
for ($i = 1; $i <= 31; $i++) {
$myDay = ($i < 10) ? '0' . $i : $i;
$html .= '<option value="' . $myDay . '"' .
preSelect(${$this->dayVar}, $myDay) . '>' . $myDay . '</option>';
}
$html .= '</select>';
return $html;
}

function getYearText() { // STRING "METHOD" TO PRODUCE YEAR TEXT
FIELD
global ${$this->yearVar};

if (!$this->hasYear) return '';
$html = '<input type="text" name="' . $this->yearVar . '" value="' .
${$this->yearVar} . '" size="' . $this->yearFieldLength . '">';
return $html;
}

}
Jul 17 '05 #1
0 1652

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dafella | last post by:
The following is code from Xeoport. It is suppose to access my pop3 account and load email into Mysql database. It's not inserting and there is no log or anything to tell me why. Here is the...
6
by: Lars Plessmann | last post by:
Hello! I try to use PHP session function, and it doesn't work properly. :-( I want to pass a whole object from site A to site B to minimize Database connections. I don't use GLOBALS = ON. My...
1
by: Esteban Felipe | last post by:
Hi, thanks for reading. I hope to find some help here before I commit suicide because this is driving me crazy. Please excuse me if this looks like a long post, but I hope that a complete...
7
by: Jim Carlock | last post by:
Does a SELECT element (listbox) need to be inside a FORM element? The code I'm playing with: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
4
by: Gary | last post by:
Hi, I get this error " " when my web page run, what does it mean? Hope someone can help!!! Gary
11
by: Joseph S. | last post by:
Hi all, how do I avoid typing the keyword "$this->" every time I need to reference a member of a class inside the class? (coming from a world of cozy auto-complete enabled Java / .Net IDEs I...
2
by: Jim Carr | last post by:
Upon entering the site www.FutureByDesign-Music.com with IE6, my clipboard is erased and then disabled in all other Windows XP applications. Navigating to another site returns clipboard...
71
by: Murray R. Van Luyn | last post by:
Hi, Since I have made changes to my website it's been a complete flop. According to the logs, as soon as visitors have downloaded the index page they are off. I can't figure out why? ...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.