-
Ajax works somehow in firefox but not at all in IE8 beta
Hi my code is below and I am new at this. I would like to calculate the amount for every ticket and post them back to the amount text field.
The Form in FITickets.php
Code:
<?php
include_once ("db.php");
//include_once("common.php");
?>
<!--
//To change this template, choose Tools | Templates
//and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="CssTest6.css"></link>
<script src="risingajax.js"></script>
</head>
<body>
<form>
<fieldset>
<legend >Your Info</legend>
<table border="0" width="100%" cellspacing="0" cellpadding="5">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>First Name</td>
<td><input type="text" name="first" value="" size="8" /></td>
<td>Last Name</td>
<td><input type="text" name="last" value="" size="8" /></td>
<td>Address</td>
<td><input type="text" name="address" value="" size="10" /></td>
</tr>
<tr>
<td>City</td>
<td><input type="text" name="city" value="" size="5" /></td>
<td>State</td>
<td><input type="text" name="state" value="" size="1" /></td>
<td>Zip</td>
<td><input type="text" name="zip" value="" size="2" /></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email" value="" size="10" /></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</fieldset>
<fieldset>
<legend>Ticket Info</legend>
<?php
dbConnect('comprise');
{
$rs = mysql_query("SELECT * FROM contributions where type = 'ticket'");
// create an array holding the classes you want to switch between
$classes=array("td1","td2");
// a counter to keep track of which class is currently being used
$classifier=0;
$num = mysql_num_rows($rs);
$i = 0;
echo "<TABLE width=100% align=left cellpadding=5 cellspacing=0>";
echo "<tr class=trhead >";
echo"<td>Description</td>";
echo"<td>Type</td>";
echo"<td>Price</td>";
echo"<td>Quantity</td>";
echo"<td>Amount</td>";
echo "</tr>";
while ($i < $num){
$description = mysql_result($rs,$i,"description");
$price= mysql_result($rs,$i,"price");
$typeid= mysql_result($rs,$i,"typeid");
//$dmiddle= mysql_result($rs,$i,"middle");
// access the value in the array associated with the key equal to the counter and print it in the <tr> bg
echo "<tr class=" . $classes[$classifier] .">";
echo "<td>" . $description . "</td>";
echo "<td>" . $typeid . "</td>";
echo "<td>" ."$". $price . "</td>";
echo '<td><input type="text" name="quantity[$i]" onkeyup = "calamount(this.value)" size="1" /></td>';
echo '<td ><input type="text" name="amount[$i]" size="3" /></td>';
$i++;
// increment the counter and mod it by 2 to effectively alternate between two numbers
$classifier=($classifier+1)%2;
}
}
echo "</table>";
?>
</fieldset>
<div align="right"><input type="submit" value="Calculate" name="pay" /></div>
</form>
<p>Suggestions: <span id="amt"></span></p>
</body>
</html>
//the javascripts is in risingajax.js
var xmlHttp
function calamount(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="ticinsert.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}function stateChanged()
{
if (xmlHttp.readyState==4 )//|| xmlHttp.readyState=="complete"
{
document.getElementById("amt").innerHTML=xmlHttp.responseText
}
}function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
//the php is in ticinsert.php
<?php
include_once ("db.php");
//include_once("common.php");
?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="CssTest6.css"></link>
</head>
<body>
<form name="ticket" action="index.php" method="POST">
<fieldset>
<legend >Your Info</legend>
<table border="0" width="100%" cellspacing="5" cellpadding="5">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>First Name:</td>
<td><?php echo $_POST[first]; ?></td>
<td>Last Name:</td>
<td><?php echo $_POST[last]; ?></td>
<td>Address:</td>
<td><?php echo $_POST[address]; ?></td>
</tr>
<tr>
<td>City:</td>
<td><?php echo $_POST[city]; ?></td>
<td>State:</td>
<td><?php echo $_POST[state]; ?></td>
<td>Zip:</td>
<td><?php echo $_POST[zip]; ?></td>
</tr>
<tr>
<td>Email:</td>
<td><?php echo $_POST[email]; ?></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</fieldset>
<fieldset>
<legend>Ticket Info</legend>
<?php
$q=$_GET["q"];
dbConnect('comprise');
{
$rs = mysql_query("SELECT * FROM contributions where type = 'ticket'");
// create an array holding the classes you want to switch between
$classes=array("td1","td2");
// a counter to keep track of which class is currently being used
$classifier=0;
$num = mysql_num_rows($rs);
$i = 0;
echo "<TABLE width=100% align=left cellpadding=5 cellspacing=0>";
echo "<tr class=trhead >";
echo"<td>Description</td>";
echo"<td>Type</td>";
echo"<td>Price</td>";
echo"<td>Quantity</td>";
echo"<td>Amount</td>";
echo "</tr>";
while ($i < $num){
$description = mysql_result($rs,$i,"description");
$price= mysql_result($rs,$i,"price");
$typeid= mysql_result($rs,$i,"typeid");
$quantity = $q[$i];
$amount = $price * $q[$i];
//$dmiddle= mysql_result($rs,$i,"middle");
// access the value in the array associated with the key equal to the counter and print it in the <tr> bg
echo "<tr class=" . $classes[$classifier] .">";
echo "<td>" . $description . "</td>";
echo "<td>" .$typeid. "</td>";
echo "<td>"."$". $price ."</td>";
echo "<td>". $quantity ."</td>";
echo "<td>". $amount ."</td>";
$i++;
// increment the counter and mod it by 2 to effectively alternate between two numbers
$classifier=($classifier+1)%2;
}
}
echo "</table>";
?>
</fieldset>
<div align="right"><input type="submit" value="Payment" name="pay" /></div>
</form>
</body>
</html>
Last edited by Hack; 01-08-2009 at 11:46 AM.
Reason: Added Code Tags
-
-
In IE after you enter something in quantity nothing displays after suggestions,
but in firefox it does.
-
Well, first off I wouldn't be concerned about something not working in a beta version of anything.
Does it work in IE7?
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
Similar Threads
-
Replies: 0
Last Post: 03-15-2007, 04:41 AM
-
By guy.murray in forum AJAX
Replies: 2
Last Post: 02-16-2007, 02:13 PM
-
By gregson09 in forum AJAX
Replies: 2
Last Post: 01-09-2007, 02:28 PM
-
By dhruba.bandopad in forum VB Classic
Replies: 2
Last Post: 06-26-2006, 12:07 PM
-
By Patrick Ireland in forum .NET
Replies: 3
Last Post: 10-08-2001, 11:41 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks