Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder MrBiggZ's Avatar
    Join Date
    Apr 2005
    Location
    Indianapolis IN
    Posts
    345
    Thanks
    44
    Thanked 2 Times in 2 Posts

    Undefined index when the index is defined! How is this?

    How do!

    I'm playing around with forms now! I needed to cramp something else in my head! And what I'm trying to get away from in this issue is writing out <option .... over and over again. I figured it'd be easier to loop through an array. But my array seems to be sick.

    Here the code I'm toying around with:

    Code:
    <?php
    
    
    function input_select($element_name, $selected, $options, $multiple = false) {
    	print '<select name="' . $element_name;
    	if ($multiple) { print '[]" multiple="multiple'; }
    	print '">';
    	$selected_options = array();
    	if ($multiple) {
    		foreach ($selected[$element_name] as $val) {
    			$selected_options[$val] = true;
    		}
    	}  else {
    		$selected_options[ $selected[$element_name] ] = true;
    	}
    	
    	foreach ($options as $option => $label) {
    		print '<option value="' . htmlentities($option) . '"';
    		if ($selected_options[$option]) {
    			print ' selected="selected"';
    		}
    		print '>' . htmlentities($label) . '</option>';
    	}
    	print '</select>';
    }
    
    
    $status = array('stop' => 'Stopped',
    						'run' => 'Running',
    						'done' => 'Completed',
    						'none' => 'None');
    
    print "<pre>". print_r($status) . "</pre><br>\n";						
    print "<hr>\n";
    print "<br>\n";
    input_select('stat', $status['none'] , $GLOBALS['status']);
    
    ?>
    In the browser where the drop down is I'm getting this crazy mess in (HTML):

    Code:
    <select name="stat"><option value="stop"<br />
    <b>Notice</b>:  Undefined index: stop in <b>C:\www\htdocs\array.php</b> on line <b>19</b><br />
    >Stopped</option><option value="run"<br />
    <b>Notice</b>:  Undefined index: run in <b>C:\www\htdocs\array.php</b> on line <b>19</b><br />
    
    >Running</option><option value="done"<br />
    <b>Notice</b>:  Undefined index: done in <b>C:\www\htdocs\array.php</b> on line <b>19</b><br />
    >Completed</option><option value="none"<br />
    <b>Notice</b>:  Undefined index: none in <b>C:\www\htdocs\array.php</b> on line <b>19</b><br />
    
    >None</option></select>
    Also .. I've seen this but why does it do it? When I use print_r I get a 1 that follow within the browser, why is that?

    Array ( [stop] => Stopped [run] => Running [done] => Completed [none] => None )

    1
    I'm pretty sure my syntax is clean. Although I was going a little goofy with all the single and double quotes!

    Thanks for any assistance!

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    This here is your problem:

    PHP Code:
    if ($selected_options[$option]) { 
    That array index will only be defined if it is selected. Otherwise it doesn't exist, and you get that notice. You need to use if (isset($selected_options[$option])) there which will not throw the notice.

    On your print_r question, print_r() will display the information, but it returns boolean "true" (which displays as a "1") unless you pass it a second parameter telling it to return the information rather than displaying it. Since you're echoing the return value of print_r, you get a 1.

    Example:
    PHP Code:
    print "<pre>"print_r($statustrue) . "</pre><br>\n"
    Last edited by Fumigator; 10-17-2009 at 07:37 AM.

  • Users who have thanked Fumigator for this post:

    MrBiggZ (10-20-2009)

  • #3
    Regular Coder MrBiggZ's Avatar
    Join Date
    Apr 2005
    Location
    Indianapolis IN
    Posts
    345
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Thanks Fum!

    That worked like a charm! And thanks for point out the mystery of the '1'

  • #4
    Regular Coder MrBiggZ's Avatar
    Join Date
    Apr 2005
    Location
    Indianapolis IN
    Posts
    345
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Back again on this 'Notice: Undefined index' warnings. It's funny because if I lay it all out in a single file it works like this:

    Code:
    <?php
    
    function input_select($element_name, $selected, $options, $drop_width = '100px', $multiple = false, $changer = false) {
    	print '<select style="width:' . $drop_width . ';" name="' . $element_name;
    	if ($multiple) { print '[]" multiple="multiple'; }
    	if ($changer) { print '" OnChange="disableJobStream(this)'; }
    	print '">' . "\n";
    	$selected_options = array();
    	if ($multiple) {
    		foreach ($selected[$element_name] as $val) {
    			$selected_options[$val] = true;
    		}
    	}  else {
    		$selected_options[ $selected[$element_name] ] = true;
    	}
    	
    	foreach ($options as $option => $label) {
    		print '<option value="' . htmlentities($option) . '"';
    		if (isset($selected_options[$option])) {
    			print ' selected="selected"';
    		}
    		print '>' . htmlentities($label) . '</option>' . "\n";
    	}
    	print '</select>' . "\n";
    }
    
    $artprog_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed');
    						
    $artprog_wfls = array('no_job' => '------- select a job -------', 'art_batch' => 'ARTPROG/WFL/DAILY/BATCH', 'art_image' =>	'ARTPROG/WFL/OPERATIONS/IMAGE', 'art_wkly_batch' => 'ARTPROG/WFL/WKLY/BATCH', 'art_claims' => 'ARTPROG/WFL/DAILY/CLAIMS');
    
    input_select('artprogs',$artprog_wfls['no_job'], $GLOBALS['artprog_wfls'], '390px');
    input_select('artprog_stat', $artprog_status['none'] , $GLOBALS['artprog_status'],'100px',false,true);
    
    ?>
    But once I start putting it in a table and put my functions in it's own php file I start getting the 'notices.'

    I'll paste in a few:

    Notice: Undefined index: artprog_wfls in C:\www\htdocs\ShiftRptForm\table.html on line 115

    Notice: Undefined index: artprog_status in C:\www\htdocs\ShiftRptForm\table.html on line 116

    Notice: Undefined index: bllyprog_wfls in C:\www\htdocs\ShiftRptForm\table.html on line 158

    Notice: Undefined index: bllyprog_status in C:\www\htdocs\ShiftRptForm\table.html on line 15

    and so on.

    I also get this one too at the start of it all:

    Notice: Undefined index: _submit_check in C:\www\htdocs\ShiftRptForm\table.html on line 34

    Here's the php/html:

    FYI: It's not doing anything at the moment. My Process_form function I was just trying to see if I could return a few values.

    If you could either show me another way to do forms/have a better solution and/or resources please do share! I just found this example and ran with it!

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    	<title>Empty Page</title>
    
    <style type="text/css">
    table {border-collapse:collapse;}
    th.thShift	{border-top:3px inset red;border-left:3px inset red;border-right:3px inset red;}
    td.tdShift	{border-bottom:3px inset red;border-left:3px inset red;border-right:3px inset red;text-align:center;}
    		
    th.jobStat1	{border-top:3px inset blue;border-left:3px inset blue;}
    th.jobStat2	{border-top:3px inset blue;}
    th.jobStat3	{border-top:3px inset blue;border-right:3px inset blue;}		
    
    td.jobStat1 {border-left:3px inset blue;}
    td.jobStat3 {border-right:3px inset blue;}
    			
    td.LastjobStat1	{border-bottom:3px inset blue;border-left:3px inset blue;}
    td.LastjobStat2	{border-bottom:3px inset blue;}
    td.LastjobStat3	{border-bottom:3px inset blue;border-right:3px inset blue;}					
    		
    tr.IC2-top	{border-top:3px inset green;border-left:3px inset green;border-right:3px inset green;}
    tr.IC2-sides	{border-left:3px inset green;border-right:3px inset green;}
    tr.IC2-bottom	{border-bottom:3px inset green;border-left:3px inset green;border-right:3px inset green;}
    </style>
    </head>
    
    <body>
    
    <?php
    
    
    
    if ($_POST['_submit_check']) {
    	process_form();
    	}
    else  {
    	show_form();
    }
    
    function show_form() {
    
    $artprog_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed');
    						
    $artprog_wfls = array('no_job' => '------- select a job -------', 'art_batch' => 'ARTPROG/WFL/DAILY/BATCH', 'art_image' =>	'ARTPROG/WFL/OPERATIONS/IMAGE', 'art_wkly_batch' => 'ARTPROG/WFL/WKLY/BATCH', 'art_claims' => 'ARTPROG/WFL/DAILY/CLAIMS');
    
    $bllyprog_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed');
    					  
    $bllyprog_wfls = array('no_job' => '------- select a job -------', 'blly_sischedpay' => 'BLLYPROG/WFL/DAILY/SISCHEDPAY', 'blly_rpts' => 'BLLYPROG/WFL/DAILY/REPORTS', 'blly_wkly_gypsum' => 'BLLYPROG/WFL/WKLY/REPORTS/GYPSUM', '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP' => '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP', 'blly_audit_close' => '$UTIL/O/AUDIT/CLOSE/BLLY', 'blly_datasiwh' => 'DATASIWH/EXTRACTALL/DAILY/AUD/WFL');
    
    $sbwcprog_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed');
    					  
    $sbwcprog_wfls = array('no_job' => '------- select a job -------', 'sbwc_warehouse' => 'WORKPROG/WFL/DAILY/WAREHOUSE', 'sbwc_archive_bkup' => '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP', 'sbwc_audit_close' => '$UTIL/O/AUDIT/CLOSE/WORKCOMP');
    					  
    $tcsprog_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed');
    						
    $tcsprog_wfls = array ('no_job' => '------- select a job -------', 'TCS/WFL/DAILY/BATCH' => 'TCS/WFL/DAILY/BATCH', 'BLPROG/WFL/COPY/REMOVE/GLCHECKS' => 'BLPROG/WFL/COPY/REMOVE/GLCHECKS');
    					  
    $icprog_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed');
    					  
    $icprog_wfls = array ('no_job' => '------- select a job -------', 'BLPROG/WFL/DAILY/INDCONT' => 'BLPROG/WFL/DAILY/INDCONT', 'INDCON/WFL/PRINT/IDCARDS' => 'INDCON/WFL/PRINT/IDCARDS', 'BLPROG/WFL/BATCH/NEWYORK/STATE-REPORT' => 'BLPROG/WFL/BATCH/NEWYORK/STATE-REPORT');
    
    $truckprog_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed');
    					 
    $truckprog_wfls = array('no_job' => '------- select a job -------', 'TRUCKPROG/WFL/DAILY/TKINTMARSH' => 'TRUCKPROG/WFL/DAILY/TKINTMARSH', 'TRUCKPROG/WFL/DAILY/TKINTERNET' => 'TRUCKPROG/WFL/DAILY/TKINTERNET', 'TRUCKPROG/WFL/DAILY/BATCH' => 'TRUCKPROG/WFL/DAILY/BATCH', 'TRUCKPROG/WFL/DAILY/TKSCHEDPAY' => 'TRUCKPROG/WFL/DAILY/TKSCHEDPAY', 'TRUCKPROG/WFL/DAILY/REPORTS' => 'TRUCKPROG/WFL/DAILY/REPORTS', 'BLPROG/WFL/DAILY/CLAIMS' => 'BLPROG/WFL/DAILY/CLAIMS', 'TRUCKPROG/WFL/DAILY/AUDIT/PREMIUM' => 'TRUCKPROG/WFL/DAILY/AUDIT/PREMIUM', 'TRUCKPROG/WFL/DAILY/BALRPT' => 'TRUCKPROG/WFL/DAILY/BALRPT', 'PROG-MEDICAL/WFL/DAILY/PMCLMEXT' => 'PROG-MEDICAL/WFL/DAILY/PMCLMEXT', 'AGPROG/WFL/DAILY/AGNUCOPREM' => 'AGPROG/WFL/DAILY/AGNUCOPREM', 'BL/WFL/WKLY/FEDEX/0005' => 'BL/WFL/WKLY/FEDEX/0005', 'TRUCKPROG/WFL/WKLY/DE542' => 'TRUCKPROG/WFL/WKLY/DE542', 'TRUCKPROG/WFL/WKLY/FDXDISAB' => 'TRUCKPROG/WFL/WKLY/FDXDISAB', 'TRUCKPROG/WFL/WKLY/FDXDISERR' => 'TRUCKPROG/WFL/WKLY/FDXDISERR', 'BL/WFL/ONLINE/DUMP/TRUCKING' => 'BL/WFL/ONLINE/DUMP/TRUCKING', 'DATATKWH/EXTRACTALL/DAILY/WFL' => 'DATATKWH/EXTRACTALL/DAILY/WFL', '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP' => '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP');
    
    $smallprog_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed');						
    						
    $smallprog_wfls = array('no_job' => '------- select a job -------', 'SMALLPROG/WFL/DAILY/BATCH' => 'SMALLPROG/WFL/DAILY/BATCH', 'SMALLPROG/WFL/DAILY/CERTS' => 'SMALLPROG/WFL/DAILY/CERTS', 'SMALLPROG/WFL/OPERATIONS/PRINT' => 'SMALLPROG/WFL/OPERATIONS/PRINT', 'SMALLPROG/WFL/WKLY/BATCH' => 'SMALLPROG/WFL/WKLY/BATCH', 'SFCLAIMS/WFL/DAILY/DWHCLAIMS' => 'SFCLAIMS/WFL/DAILY/DWHCLAIMS', 'SFCLAIMS/WFL/DAILY/REPORTS' => 'SFCLAIMS/WFL/DAILY/REPORTS', 'SFCLAIMS/WFL/WEEKLY/REPORTS' => 'SFCLAIMS/WFL/WEEKLY/REPORTS', 'BL/WFL/ONLINE/DUMP/SFDB/1WORKER' => 'BL/WFL/ONLINE/DUMP/SFDB/1WORKER', '$UTIL/O/AUDIT/CLOSE/SFDB' => '$UTIL/O/AUDIT/CLOSE/SFDB', 'DATASFWH/EXTRACTALL/DAILY/WFL' => 'DATASFWH/EXTRACTALL/DAILY/WFL', '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP' => '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP');
    
    $persauto_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed');						
    						
    $persauto_wfls = array('no_job' => '------- select a job -------', 'PERSAUTO/WFL/DAILY/BATCH' => 'PERSAUTO/WFL/DAILY/BATCH', 'PERSAUTO/WFL/OPERATIONS/IMAGE' => 'PERSAUTO/WFL/OPERATIONS/IMAGE', 'PERSAUTO/WFL/OPERATIONS/PRINT' => 'PERSAUTO/WFL/OPERATIONS/PRINT', 'PERSAUTO/WFL/WKLY/BATCH' => 'PERSAUTO/WFL/WKLY/BATCH', 'PERSAUTO/WFL/DAILY/CLAIMS' => 'PERSAUTO/WFL/DAILY/CLAIMS', 'BL/WFL/ONLINE/DUMP/DB1/1WORKER/FULL' => 'BL/WFL/ONLINE/DUMP/DB1/1WORKER/FULL', '$UTIL/O/AUDIT/CLOSE/DB1' => '$UTIL/O/AUDIT/CLOSE/DB1', 'DATAWH/EXTRACTALL/DAILY/WFL' => 'DATAWH/EXTRACTALL/DAILY/WFL', 'BL/WFL/OFFLINE/DUMP/WAREHOUSE' => 'BL/WFL/OFFLINE/DUMP/WAREHOUSE');
    
    $isoprog_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed');						
    
    $isoprog_wfls = array('no_job' => '------- select a job -------', 'ISOPROG/WFL/BATCH/ISOSAGDAILY' => 'ISOPROG/WFL/BATCH/ISOSAGDAILY');
    					  
    $bkuplive_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed');
    						
    $bkuplive_wfls = array('no_job' => '------- select a job -------', 'BL/WFL/ONLINE/DUMP/BLDB' => 'BL/WFL/ONLINE/DUMP/BLDB', '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP' => '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP', '$UTIL/O/AUDIT/CLOSE/BLDB' => '$UTIL/O/AUDIT/CLOSE/BLDB', 'DATARDWH/EXTRACTALL/DAILY/REIN/WFL' => 'DATARDWH/EXTRACTALL/DAILY/REIN/WFL', '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP' => '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP', 'BL/WFL/FICHE/DISK' => 'BL/WFL/FICHE/DISK');
    					  
    $testsite_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed');
    						
    $testsite_wfls = array('no_job' => '------- select a job -------', 'WFL/TESTLYON/DATABASE/ONLINE/DISABLE' => 'WFL/TESTLYON/DATABASE/ONLINE/DISABLE', 'UTIL/WFL/REMOVE/TESTLYON/BDFILES' => 'UTIL/WFL/REMOVE/TESTLYON/BDFILES', 'BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP' => 'BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP');
    
    include_once('form_input_functions.php');
    
    ?>
    
    <form method="POST" name="shiftreport" action="<?php print $_SERVER['PHP_SELF']; ?>">
    <table name="shifttable">
    	<thead>
    		<tr>
    			<th class="thShift" colspan="5">Shift</th>
    		</tr>
    	</thead>	
    	<tbody>
    		<tr>
    			<td class="tdShift" colspan="5">1st <?php input_radiocheck('radio','shift','0','1',true); ?>&nbsp;&nbsp;&nbsp;2nd <?php input_radiocheck('radio','shift','0','2',true); ?>&nbsp;&nbsp;&nbsp;3rd <?php input_radiocheck('radio','shift','0','3',true); ?></td>
    		</tr>
    	</tbody>
    		<tr><td colspan="5"></td></tr>
    	<thead>
    		<tr>
    			<th class="jobStat1">Application</th>
    			<th class="jobStat2">Job Stream</th>
    			<th class="jobStat3">Status</th>
    		</tr>
    	</thead>
    	
    	<tbody>
    		<tr>
    			<td class="jobStat1">ARTISAN</td>
    			<td><?php input_select('artprogs',$artprog_wfls['no_job'], $GLOBALS['artprog_wfls'], '390px'); ?></td>
    			<td class="jobStat3"><?php input_select('artprog_stat', $artprog_status['none'] , $GLOBALS['artprog_status'],'100px',false,true); ?></td>
    			<td></td>
    			<td rowspan="11" vertical-align="baseline">
    				<table>
    					<thead>
    						<tr class="IC2-top" >
    							<th colspan="2">IC2 Output</th>
    						</tr>
    					</thead>
    					<thead>
    						<tr class="IC2-sides">
    							<th>Data</th>
    							<th>File Count</th>
    						</tr>
    					</thead>
    					<tbody>
    						<tr class="IC2-sides">
    							<td>Group Sponsor Mail</td>
    							<td><?php echo "<select name=\"Grp_Count\">";$i = 0;while ( $i <= 500 ) { echo "<option value=".$i.">".$i."</option>"; $i++; } echo "</select>"; ?></td>
    						</tr>
    						<tr class="IC2-sides">
    							<td>Insured Mail</td>
    							<td><?php echo "<select name=\"Ins_Count\">";$i = 0;while ( $i <= 500 ) { echo "<option value=".$i.">".$i."</option>"; $i++; } echo "</select>"; ?></td>
    						</tr>						
    						<tr class="IC2-sides">
    							<td>Lienholder Mail</td>
    							<td><?php echo "<select name=\"Lnh_Count\">";$i = 0;while ( $i <= 500 ) { echo "<option value=".$i.">".$i."</option>"; $i++; } echo "</select>"; ?></td>
    						</tr>
    						<tr class="IC2-sides">
    							<td>State Mail</td>
    							<td><?php echo "<select name=\"Stm_Count\">";$i = 0;while ( $i <= 500 ) { echo "<option value=".$i.">".$i."</option>"; $i++; } echo "</select>"; ?></td>
    						</tr>
    						<tr class="IC2-sides IC2-bottom">
    							<td>Work Accident Insured Mail</td>
    							<td><?php echo "<select name=\"Wam_Count\">";$i = 0;while ( $i <= 500 ) { echo "<option value=".$i.">".$i."</option>"; $i++; } echo "</select>"; ?></td>
    						</tr>							
    					</tbody>
    				</table>
    			</td>
    		</tr>
    		<tr>
    			<td class="jobStat1">SELF INSURED</td>
    			<td><?php input_select('bllyprogs',$bllyprog_wfls['no_job'], $GLOBALS['bllyprog_wfls'], '390px'); ?></td>
    			<td class="jobStat3"><?php input_select('bllyprog_stat', $bllyprog_status['none'] , $GLOBALS['bllyprog_status']); ?></td>
    		</tr>
    		<tr>
    			<td class="jobStat1">SBWC</td>
    			<td><?php input_select('sbwcprogs',$sbwcprog_wfls['no_job'],$GLOBALS['sbwcprog_wfls'], '390px'); ?></td>
    			<td class="jobStat3"><?php input_select('sbwcprog_stat', $sbwcprog_status['none'] , $GLOBALS['sbwcprog_status']); ?></td>
    		</tr>
    		<tr>
    			<td class="jobStat1">TCS</td>
    			<td><?php input_select('tcsprogs',$tcsprog_wfls['no_job'], $GLOBALS['tcsprog_wfls'], '390px'); ?></td>
    			<td class="jobStat3"><?php input_select('tcsprog_stat', $tcsprog_status['none'] , $GLOBALS['tcsprog_status']); ?></td>			
    		</tr>
    		<tr>
    			<td class="jobStat1">IC</td>
    			<td><?php input_select('icprogs',$icprog_wfls['no_job'], $GLOBALS['icprog_wfls'], '390px'); ?></td>
    			<td class="jobStat3"><?php input_select('icprog_stat', $icprog_status['none'] , $GLOBALS['icprog_status']); ?></td>			
    		</tr>
    		<tr>
    			<td class="jobStat1">TRUCKING</td>
    			<td><?php input_select('truckprogs',$truckprog_wfls['no_job'], $GLOBALS['truckprog_wfls'], '390px'); ?></td>
    			<td class="jobStat3"><?php input_select('truckprog_stat', $truckprog_status['none'] , $GLOBALS['truckprog_status']); ?></td>			
    		</tr>
    		<tr>
    			<td class="jobStat1">SMALL FLEET</td>
    			<td><?php input_select('smallprogs',$smallprog_wfls['no_job'], $GLOBALS['smallprog_wfls'], '390px'); ?></td>
    			<td class="jobStat3"><?php input_select('smallprog_stat', $smallprog_status['none'] , $GLOBALS['smallprog_status']); ?></td>			
    		</tr>
    		<tr>
    			<td class="jobStat1">PERSONAL AUTO</td>
    			<td><?php input_select('persauto',$persauto_wfls['no_job'], $GLOBALS['persauto_wfls'], '390px'); ?></td>
    			<td class="jobStat3"><?php input_select('persauto_stat', $persauto_status['none'] , $GLOBALS['persauto_status']); ?></td>			
    		</tr>
    		<tr>
    			<td class="jobStat1">ISO</td>
    			<td><?php input_select('isoprog',$isoprog_wfls['no_job'], $GLOBALS['isoprog_wfls'], '390px'); ?></td>
    			<td class="jobStat3"><?php input_select('isoprog_stat', $isoprog_status['none'] , $GLOBALS['isoprog_status']); ?></td>			
    		</tr>
    		<tr>
    			<td class="jobStat1">BACKUPS LIVE</td>
    			<td><?php input_select('bkuplive',$bkuplive_wfls['no_job'], $GLOBALS['bkuplive_wfls'], '390px'); ?></td>
    			<td class="jobStat3"><?php input_select('bkuplive_stat', $bkuplive_status['none'] , $GLOBALS['bkuplive_status']); ?></td>			
    		</tr>
    		<tr>
    			<td class="jobStat1 LastjobStat1">TEST SITE INSTRUCTIONS</td>
    			<td class="LastjobStat2"><?php input_select('testsite',$testsite_wfls['no_job'], $GLOBALS['testsite_wfls'], '390px'); ?></td>
    			<td class="jobStat3 LastjobStat3"><?php input_select('testsite_stat', $testsite_status['none'] , $GLOBALS['testsite_status']); ?></td>			
    		</tr>
    	</tbody>
    
    </table>
    <input type="submit" value="Submit">
    <input type="hidden" value="_submit_check" value="1">
    </form>
    <?php 
    	}
    
    function process_form() {
    print "Shift: " . $_POST['shift'];
    print "Artprog: " . $_POST['artprogs'];
    print "Artprog Status: " . $_POST['artprog_stat'];
    }	
    	?>
    </body>
    </html>
    This is the function script:

    Code:
    <?php 
    
    function input_text($element_name, $value) {
    	print '<input type="text" name="' . $element_name . '" value="';
    	print htmlentities($values[$element_name]) . '">';
    }
    
    function input_submit($element_name,$label) {
    	print '<input type="submit" name="' . $element_name .'" value="';
    	print htmlentities($label) .'"/>';
    }
    
    function input_textarea($element_name,$values) {
    	print '<textarea name="' . $element_name . '">';
    	print htmlentities($values[$element_name]) . '</textarea>';
    }
    
    function input_radiocheck($type,$element_name,$values,$element_value,$clicker = false) {
    	print '<input type="' . $type . '" name="' . $element_name . '" value="' . $element_value . '" ';
    	if ($element_value == $values[$element_name]) {
    		print ' checked="checked"';
    	}
    	if ($clicker) print ' onclick="setReadOnly(this)"';
    	print '/>';
    }
    
    function input_select($element_name, $selected, $options, $drop_width = '100px', $multiple = false, $changer = false) {
    	print '<select style="width:' . $drop_width . ';" name="' . $element_name;
    	if ($multiple) { print '[]" multiple="multiple'; }
    	if ($changer) { print '" OnChange="disableJobStream(this)'; }
    	print '">' . "\n";
    	$selected_options = array();
    	if ($multiple) {
    		foreach ($selected[$element_name] as $val) {
    			$selected_options[$val] = true;
    		}
    	}  else {
    		$selected_options[ $selected[$element_name] ] = true;
    	}
    	
    	foreach ($options as $option => $label) {
    		print '<option value="' . htmlentities($option) . '"';
    		if (isset($selected_options[$option])) {
    			print ' selected="selected"';
    		}
    		print '>' . htmlentities($label) . '</option>' . "\n";
    	}
    	print '</select>' . "\n";
    }
    ?>
    I found something else while looking around. I found this in the HTML source; Invalid argument supplied for foreach() I still don't understand why it works properly if I run it from it's own script. Should I even bother doing forms this way or am I just creating my problems for myself?

    Code:
    			<td class="jobStat1">ARTISAN</td>
    
    			<td><br />
    <b>Notice</b>:  Undefined index: artprog_wfls in <b>C:\www\htdocs\ShiftRptForm\table.html</b> on line <b>115</b><br />
    <select style="width:390px;" name="artprogs">
    <br />
    <b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\www\htdocs\ShiftRptForm\form_input_functions.php</b> on line <b>41</b><br />
    
    </select>
    </td>
    			<td class="jobStat3"><br />
    <b>Notice</b>:  Undefined index: artprog_status in <b>C:\www\htdocs\ShiftRptForm\table.html</b> on line <b>116</b><br />
    <select style="width:100px;" name="artprog_stat" OnChange="disableJobStream(this)">
    <br />
    <b>Warning</b>:  Invalid argument supplied for foreach() in <b>C:\www\htdocs\ShiftRptForm\form_input_functions.php</b> on line <b>41</b><br />
    
    </select>
    </td>
    As always Thanks for the Help! ( I was kicking butt for a minute and then my minute ran out )
    Last edited by MrBiggZ; 10-24-2009 at 03:51 AM. Reason: addition


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •