Click to See Complete Forum and Search --> : Browser Compatibility Issues


phildiggle
05-05-2009, 10:41 AM
Hi All,

Still on with my cart script, which is near completion now. However, I've got a problem with one form which doesn't seem to be compatible in Internet Explorer, yet when used in Firefox - the form works fine!!!

What I'm trying to do is to view the order details, then if the status of the order has changed to select a value from a drop down list which when the person clicks modify will alter the value within the database entry.

Relevent bits of code are:


detail.php
<?
//Create Drop Down List
$orderStatus = array('New', 'Paid', 'Shipped', 'Completed', 'Cancelled');
$orderOption = '';
foreach ($orderStatus as $status) {
$orderOption .= "<option value='$status'">$status</option> \r \n";
}
?>

<form action="processOrder.php" method="post" name="frmOrder" id="frmOrder">
Last Update: <?php echo $od_last_update; ?><br>
Status:
<select name="cboOrderStatus" id="cboOrderStatus" class="box">
<?php echo $orderOption; ?> </select>
<input name="btnModify" type="button" id="btnModify" value="Modify Status" class="box" onClick="modifyOrderStatus(<?php echo $orderId; ?>);"></form>


processOrder.php
<?
function modifyOrder()
{
if (!isset($_GET['oid']) || (int)$_GET['oid'] <= 0
|| !isset($_GET['status']) || $_GET['status'] == '') {
header('Location: index.php');
}

$orderId = (int)$_GET['oid'];
$status = $_GET['status'];

$sql = "UPDATE tbl_order
SET od_status='$status',od_last_update = NOW()
WHERE od_id = $orderId";
$result = dbQuery($sql);

header("Location: index.php?view=list&status=$status");
}
?>

order.js
function viewOrder()
{
statusList = window.document.frmOrderList.cboOrderStatus;
status = statusList.options[statusList.selectedIndex].value;

if (status != '') {
window.location.href = 'index.php?status=' + status;
} else {
window.location.href = 'index.php';
}
}

function modifyOrderStatus(orderId)
{
statusList = window.document.frmOrder.cboOrderStatus;
status = statusList.options[statusList.selectedIndex].value;
window.location.href = 'processOrder.php?action=modify&oid=' + orderId + '&status=' + status;
}

function deleteOrder(orderId)
{

}

I've omitted a lot of the code in detail.php because its all irrelevant.


The code works only in Firefox, but doesnt work in Internet Explorer. However, in Internet Explorer it shows the Last Update time as correct so I know this bit works, but for some reason the script wont change the order status.

Any ideas anyone?

ixalmida
05-06-2009, 12:01 PM
I think this thread needs to be moved to "Client Technologies". PHP won't be affected by different browsers since it is a server technology, but Javascript will. I've had similar issues before, but I can usually fix it by updating my Javascript. There's a lot of obsolete Javascript code out on the web so you have to be careful not to use code that is no longer fully supported. Unfortunately, I'm not a Javascript expert (yet) so I'm not sure which part of your script is the issue.

Also, this line is messed up, with an extra double-quote and no backslashes for r & n: $orderOption .= "<option value='$status'">$status</option> r n"; ...but I'll assume that isn't how it looks in your actual code.

bradgrafelman
05-06-2009, 12:19 PM
It looks like what you're doing is passing the values of the form data in the URL to another script.

Basically, you're emulating a from being posted via the GET method, so why don't you just get rid of all of the Javascript and simply use the GET method instead?