Jump to content


Member Since 05 May 2011
Offline Last Active Private

Topics I've Started

Ajax Script stopping at certain points

28 June 2013 - 11:12 PM

**Admin, please delete this as I didn't mean to post it in the end.**

Onsubmit not firing in firefox

28 June 2013 - 09:35 PM



I have piece of code I have written that, when the form is submitted it sends the string from the textbox through ajax, through a database and returns a name corresponding to that string. It works fine in chrome but not in firefox and I was wondering if you could help.

If I set the function to a simple alert(code) it will fire it and work fine however when I revert it to the ajax script it simply reloads the page with the "?code=string" and ignores anything and everything in the js function.


This is the ajax code:

function signin(code)
// event.preventDefault();
var xmlhttp;
var photo;
if (code=="")
if (window.XMLHttpRequest)
 {// code for IE7+, Firefox, Chrome, Opera, Safari
 xmlhttp=new XMLHttpRequest();
 {// code for IE6, IE5
 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 if (xmlhttp.readyState==4 && xmlhttp.status==200)
var str = xmlhttp.responseText;
var split = str.split(", ");
if(!(split['2'] == undefined)){
document.getElementById("webcamcanvas").innerHTML="<img src='" +split['2']+"' width='400' height='300'>"; 

This is the HTML form:

form onsubmit="signin(codeform.codetextbox.value)" name="codeform">
<input type="textbox" name="codetextbox" id="codetextbox" />
The reason it has no submit button is because firstly, it clutters up the page and secondly I'm using a barcode scanner which automatically inserts a carriage return, submitting the form.
Any help would be greatly appreciated!
Also, I'm sorry if this is in the wrong section, it's to do with both JS and Ajax and I didn't know which to choose.

Sending SMS via PHP layout help

27 February 2013 - 09:00 PM

 Can someone delete this post please, I didn't mean to post it in the end as I sorted my problem.

AJAX Refresh Item List Qty

18 February 2013 - 03:04 AM

Hi guys,

I'm a real newbie to AJAX and I've dived straight in at the deep end. I have a list of items that I am pulling from a database with a quantity displayed next to them. The quantity is constantly changing and I want this to be automatically updated on the page without having to refresh it.

This is the PHP for the list:

while($sweet_counter < $sweet_numbers) {

if($cellcnt == 1){
	 $shelfpart = "shelf-two.png";
elseif($cellcnt == 2){
	 $shelfpart = "shelf-three.png";
elseif($cellcnt == 3){
	 $shelfpart = "shelf-three.png";
elseif($cellcnt == 4){
	 $shelfpart = "shelf-four.png";

$itemname = mysql_result($sweet_result,$sweet_counter,'item_name');
$item_stock = mysql_result($sweet_result,$sweet_counter,'item_stock');
	 $item_id = mysql_result($sweet_result,$sweet_counter,'item_id');
	 $item_cost = mysql_result($sweet_result,$sweet_counter,'item_cost');
$new_itemname = wordwrap($itemname, 10, "<br />\n");

$sweetslist[] = '
	 <td width="242" height="194" style="background-image: url(\'images/shelf/' . $shelfpart . '\'); background-repeat: no-repeat">
		 <div id="item_wrapper">
		 <div id="item_name">
		 ' . $new_itemname . '
		 <br />
		 <br />
		 ' . $item_cost . 'p
		 <div id="item_stock">
		 <span class="counter stock" id="counter stock">
		 <div id="item_id_stock_' . $item_id . '">
			 ' . $item_stock . '

$newnumber_to_count = $sweet_numbers - 1;

if($sweet_counter == $newnumber_to_count){
	 $sweetslist[] = '<td width="35" height="194" style="background-image: url(\'images/shelf/shelf-five.png\'); background-repeat: no-repeat">
else if ($cellcnt == 4) {
	 $sweetslist[] = '<td width="35" height="194" style="background-image: url(\'images/shelf/shelf-five.png\'); background-repeat: no-repeat">
	 </td></tr><tr><td width="35" height="194" style="background-image: url(\'images/shelf/shelf-one.png\'); background-repeat: no-repeat"> &nbsp; </td>';
$cellcnt = 0;


I have already made a few AJAX scripts work fine but this is absolutely confusing me as to how I could do it to update each quantity on the page when it is changed. Any help would be greatly appreciated.

Many thanks!

Setting session with onclick jquery

09 February 2013 - 10:57 PM

I was wondering if it is at all possible to start a session in PHP using an onclick="" ?

I cannot find anything useful on google and I seem to fail everytime I try myself