PDA

View Full Version : submit no longer works in IE


beanfair
09-18-2006, 12:33 AM
:confused:
This page worked fine when the crop count was <30 now that it has been raised to 45, the submit button no longer works in IE. It does work in Mozilla.
<?php
require_once('XXX.php');
//******************* insert_zenMasterPackfromTemplateA.php ***********
// created by: jeramie
// on: may 17th, 2k6
//
// desc. attempt to produce the same information required by insert_zenMasterPackB.php
// in this step we will display the markets the user is creating
// a packing sheet for, and then display the 'current' crops from the last
// packing sheet. after which, we will display a list of crops that the user could select
// and add to the list.
//
// insert_zenMasterPackB.php depends upon: - we'll be changing masterPackB to incorporate
// use of $_GET so that error checking still takes place on the relevant pages
//
// $_POST/$_GET:
// ['number_of_markets'] - it's a numbah
// ['mkt' . $i] - in that chron order, if'n ya please, 0...m
// ['mktWk'] - (21 = may 15-22 or something like that)
// ['number_of_crops'] - usually 30
// ['crop' . $i] - , 0...c
// in the form of: $_POST/$_GET['crop0']=>arugula|ar|case
// name, abbrev, packUnit
//
// information coming in on $_GET from insert_zenMasterPackfromTemplate.php
// $_GET
// ['mktWk'] - number of the mktWk
// ['mkt'0...m] - string to build an array of info in the form of:
// $_GET['mkt0']=>cc|Columbia City|615, split on this to make
// it more useful
// ['number_of_markets'] = number of markets
// ['lastMktWk'] = that last market week
//
//*********************************************************************

//if you want to change the number of crops that are possible on one packing sheet,
//change this number.
$absolute_total_number_of_crops = 45;

if(isset($_GET['submit']))
{

$crop_list = array();
//check for crops to be removed
//explode on $_GET['last_weeks_crops'], => arugula|ar|case
for( $i=0; $i<$_GET['total_last_weeks_crops']; $i++)
{
list($cropName, $cropAbbrev, $cropPackUnit) = explode( "|", $_GET['last_weeks_crop' . $i] );
//need to remove any entries in there that are in the 'remove_<<crop abbrev>>' GET
if( !isset($_GET['remove_' . $cropAbbrev]) )
{
$crop_list[] = array('cropName'=>$cropName,
'cropAbbrev'=>$cropAbbrev,
'cropPackUnit'=>$cropPackUnit);
}

}//end for remove loop
//now we have the crops from last week in $crop_list

//add crops they wanted to add from drop downies
for( $i=0; $i<($absolute_total_number_of_crops-$_GET['total_last_weeks_crops']); $i++)
{
//add this stuff if it's set
if( isset($_GET['crop' . $i]) && $_GET['crop' . $i] != "null" )
{
list($cropName, $cropAbbrev, $cropPackUnit) = explode( "|", $_GET['crop' . $i] );
//make sure it's not already in there, if user selects two of the same crop...
$exists = false;

foreach( $crop_list as $crop )
{
if( in_array($cropAbbrev, $crop ) )
{
$exists = true;
}
}//iterate through already existing crops in crop list to make sure we're not getting multiples

if(!$exists)
{
$crop_list[] = array('cropName'=>$cropName,
'cropAbbrev'=>$cropAbbrev,
'cropPackUnit'=>$cropPackUnit);
}//end check to see if already inserted (can happen if user selects two of same crop)

}//end iffset check


}//end add part loop

//now.. where were we?
//$_POST/$_GET:
// ['number_of_markets'] - it's a numbah
// ['mkt' . $i] - in that chron order, if'n ya please, 0...m, just the abbrev
// ['mktWk'] - (21 = may 15-22 or something like that)
// ['number_of_crops'] - usually 30
// ['crop' . $i] - , 0...c
// in the form of: $_POST/$_GET['crop0']=>arugula|ar|case
// name, abbrev, packUnit
$location = sprintf("insert_zenMasterPackB.php?mktWk=" . $_GET['mktWk']);

$location .= sprintf("&number_of_markets=" . $_GET['number_of_markets']);
$location .= sprintf("&number_of_crops=" . $_GET['number_of_crops']);
$location .= sprintf("&lastMktWk=" . $_GET['lastMktWk']);
//pack the crops in and outputtem
$i=0;
foreach( $crop_list as $crop )
{
$location .= sprintf("&crop" . $i . "=" . $crop['cropName'] .
"|" . $crop['cropAbbrev'] .
"|" . $crop['cropPackUnit'] );
$i++;
}

//do the same thing with mkts.. sort of
for($i=0; $i<$_GET['number_of_markets']; $i++)
{
//list( $abbrev, $name, $number ) = explode( "|", $_GET['mkt' . $i] );

$location .= sprintf("&mkt" . $i . "=" . $_GET['mkt' . $i]);

}
//last but not least
$location .= sprintf("&useGET=true");
header( "Location: " . $location );
//echo($location);
//print_r($crop_list);

}

$number_of_markets = $_GET['number_of_markets'];//also need to set this on post
$mktWk = $_GET['mktWk'];

//ahma get some date info to make purdy
$wk_range_q = ("SELECT tblMktWk.startDate, tblMktWk.stopDate
FROM tblMktWk WHERE yrWk =" . $mktWk);
$wk_range_handle = mysql_query($wk_range_q, $zen) or die(mysql_error());
$wk_range = mysql_fetch_assoc($wk_range_handle);

//need to display the markets that the user is doing
//get that info
$last_mkts = array();
for($i=0; $i<$number_of_markets; $i++)
{
list($mktAbbrev, $mktName, $mktNum) = explode("|", $_GET['mkt' . $i]);
$last_mkts[] = array('mktAbbrev'=>$mktAbbrev,
'mktName'=>$mktName,
'mktNum'=>$mktNum);

}//end for loop
//last_mkts has a listing of the market info [0][info] in chron order no less

//we need a crop listing from the last packing sheet. cuz it's phun.
$lastMktWk = $_GET['lastMktWk'];
//use this to get the crops
$last_crops_q = sprintf("SELECT DISTINCT tblMasterPack.crop AS cropAbbrev, tblCrop.crop AS cropName, tblCrop.packUnit
FROM tblMasterPack
INNER JOIN tblCrop ON tblMasterPack.crop = tblCrop.cropID
WHERE tblMasterPack.mktWk = " . $lastMktWk . "
ORDER BY tblCrop.batch ASC");
$last_crops_handle = mysql_query($last_crops_q, $zen ) or die(mysql_error());
//use this handle wisely, my son
$last_crop_total = mysql_num_rows( $last_crops_handle );

$last_crops_arr = array();
$one_crop = mysql_fetch_assoc( $last_crops_handle );
do
{
$last_crops_arr[] = array( 'cropName'=>$one_crop['cropName'],
'cropAbbrev'=>$one_crop['cropAbbrev'],
'packUnit'=>$one_crop['packUnit'] );

}while( $one_crop = mysql_fetch_assoc( $last_crops_handle ));

//now we need generic crops to add to our list of joy
$crop_q = "SELECT tblCrop.cropID, tblCrop.crop, tblCrop.packUnit
FROM tblCrop WHERE tblCrop.ours ='Y'
AND tblCrop.current = 'Y'
AND tblCrop.cropID NOT LIKE 'cust%' ORDER BY tblCrop.crop";

$crop_handle = mysql_query($crop_q, $zen) or die(mysql_error());
//got teh crops of sorts.
//set teh number of crops to be displayed. try not to go over 30, but it doesn't really matter. we'll
//just have to set the number of crops var anyways when passing ahead
$number_of_crops = ($absolute_total_number_of_crops - $last_crop_total);

include('headernav.txt');

?>
<h2>Master Packing from Template</h2>
<h3>Add/Remove Crops</h3>
<h4>Market Week <?= date("M d, Y ", strtotime($wk_range['startDate']) ) ?> -
<?= date("M d, Y ", strtotime($wk_range['stopDate']) ) ?></h4>
<p><span style="color:red;"><?= $error ?></span></p>
<p>Something wrong with the markets below? (ie. wrong one, missing one...etc)
<a href="javascript:history.back()"> Click Here </a> to fix that!</p>
<form action="<?= $PHP_SELF ?>" name="teh cropzores" enctype="multipart/form-data" method="get">
<table border="1">
<tr>
<th colspan="<?= $number_of_markets ?>" style="color:white; font-size:smaller;">Selected Markets</th>
</tr>
<tr style="font-size:x-small;">
<?
$i = 0;
foreach( $last_mkts as $mkt )
{
?>
<td><?= $mkt['mktName'] ?>
<input type="hidden" name="mkt<?= $i ?>" value="<?= $mkt['mktAbbrev'] ?>" /></td>
<?
$i++;
}
?>
</tr>
</table><br />
<br />
<table border="0">
<tr>
<td>
<table border="1" cellpadding="2">
<tr>
<th colspan="2" style="color:white;">Crops from the last packing sheet</th>
</tr>
<tr>
<td style="font-size: xx-small;">Check to<br /><span style="color:red; font-weight: bold;">Remove</span></td>
<td style="font: smaller; font-weight: bold;">Crops</td>
</tr>
<?
//cropAbbrev
//cropName
for($i=0; $i<count($last_crops_arr);$i++)
{
?>
<tr>
<td><input type="checkbox" name="remove_<?= $last_crops_arr[$i]['cropAbbrev'] ?>"
<?php
if( isset($_GET['remove_' . $last_crops_arr[$i]['cropAbbrev']]) )
{
echo(" checked='checked' ");
}
?>
/></td>
<td><?= $last_crops_arr[$i]['cropName'] ?></td>
</tr>
<?
}//end iteration
?>
</table>
</td>
<td>
<table border="1" cellpadding="2">
<tr>
<th style="color:white;">Would you like to add crops?</th>
</tr>
<tr>
<td style="font-size: xx-small;">Select one to <span style="color: #559F00; font-weight: bold;">Add</span></td>
</tr>
<tr>
<td>
<div style="height: 350px; overflow:auto;">
<?
for( $i = 0; $i <= $number_of_crops; $i++ )
{
?>


<label>crop
<select name="crop<?= $i ?>">
<option value="null">Select a crop</option>
<?php
$crop_row = mysql_fetch_assoc( $crop_handle );

do
{
$exists = false;

foreach( $last_crops_arr as $crop_arr )
{

if( in_array( $crop_row['cropID'], $crop_arr ) )
{
$exists = true;
}
}//end crop redundancy check

if( !$exists )
{
?>
<option value="<?php echo ($crop_row['crop'] . "|" . $crop_row['cropID'] . "|" . $crop_row['packUnit']);?>"><?php echo $crop_row['crop']?></option>
<?php

}//now only crops show up once

} while ($crop_row = mysql_fetch_assoc($crop_handle));


$rows = mysql_num_rows($crop_handle);
if($rows > 0)
{
mysql_data_seek($crop_handle, 0);
}//reset pointer
?>
</select>
</label><br />

<?
}//end for loop
?>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<input type="hidden" name="number_of_crops" value="<?= $absolute_total_number_of_crops ?>" />
<input type="hidden" name="number_of_markets" value="<?= $number_of_markets ?>" />
<input type="hidden" name="lastMktWk" value="<?= $lastMktWk ?>" />
<input type="hidden" name="mktWk" value="<?= $mktWk ?>" />
<?
$i=0;
foreach($last_mkts as $mkt)
{
?>
<input type="hidden" name="mkt<?= $i ?>" value="<?= $mkt['mktAbbrev'] . "|"
. $mkt['mktName'] . "|"
. $mkt['mktNum'] ?>" />

<?

$i++;
}
?>
<?
$i=0;
foreach($last_crops_arr as $one_crop)
{
?>
<input type="hidden" name="last_weeks_crop<?= $i ?>" value="<?= $one_crop['cropName'] . "|"
. $one_crop['cropAbbrev'] . "|"
. $one_crop['packUnit'] ?>" />

<?

$i++;
}
?>
<input type="hidden" name="total_last_weeks_crops" value="<?= $i ?>" />
<input type="submit" name="submit" value="Submit" />

</form>
<?

include('footer.txt');

?>
Since the customer refuses to use Moxilla, I have a problem :-(

Fumigator
09-18-2006, 04:19 AM
If it's a browser problem then it's most likely a markup problem. Try validating the html and see what happens.

_Aerospace_Eng_
09-18-2006, 04:21 AM
Hmm a name can't have a space in it. I noticed your name of the form has a space in it. Try fixing that. Also this might be better to use
if(isset($_GET['submit']) && $_GET['submit'] == 'Submit')
{
I think the above catches the enter key as well.

beanfair
09-18-2006, 06:26 AM
I have tried validating the html, changing the form name and changing the check on the submit.
It still does nothing in IE:mad:

Any other suggestions?

raf
09-18-2006, 08:36 AM
this is a wild shot but i see you use the get-method --> the amount of data that you can send through the get-collection is limited, and that limit is browserspecific.
so it's very well possible that by expanding your form (from 30 to 45 crops), you've exceeded the IE limit for the get-collection, which would make it chop of the submit-variable.

maybe add in a
print_r($_GET);
before the check on the submitbutton to make sure it's still posted.

if this is the cause, then your only sollutions are shortening your formfieldnames and values, or using the post-method to send the form.