Jump to content

CatDogAB

New Members
  • Posts

    4
  • Joined

  • Last visited

CatDogAB's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey got a new question, thought I'd use the same thread. I have this which loads my XML file of "Items" (Javascript) function Ajax(){ var xmlHttp; try{ xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari } catch (e){ try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer } catch (e){ try{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ alert("No AJAX!?"); return false; } } } xmlHttp.onreadystatechange=function(){ if(xmlHttp.readyState==4){ txt="<table border='1'><tr><th>Name</th><th>Price</th><th>Item Code</th><th>Cart</th></tr>"; x=xmlHttp.responseXML.documentElement.getElementsByTagName("item"); for (i=0;i<x.length;i++){ xx=x[i].getElementsByTagName("quantity"); if ((xx[0].firstChild.nodeValue)>0){ txt=txt + "<tr>"; xx=x[i].getElementsByTagName("name"); { try { txt=txt + "<td>" + xx[0].firstChild.nodeValue + "</td>"; } catch (er) { txt=txt + "<td> </td>"; } } xx=x[i].getElementsByTagName("price"); { try { txt=txt + "<td>" + xx[0].firstChild.nodeValue + "</td>"; } catch (er) { txt=txt + "<td> </td>"; } } xx=x[i].getElementsByTagName("itemcode"); { try { txt=txt + "<td>" + xx[0].firstChild.nodeValue + "</td>"; } catch (er) { txt=txt + "<td> </td>"; } try { txt=txt + "<td><button>Add to cart</button></td>"; } catch (er) { txt=txt + "<td> </td>"; } } txt=txt + "</tr>"; } } txt=txt + "</table>"; document.getElementById('ReloadThis').innerHTML=txt; setTimeout('Ajax()',5000); } } xmlHttp.open("GET",'data/items.xml',true); xmlHttp.send(null); } window.onload=function(){ setTimeout('Ajax()',5000); } Which makes this: My question is, how can it so when the button is pressed on a product "Add to cart" it automatically shows up down the bottom? Any point in the right direction would be helpful.
  2. Thanks a shit load man. Appreciate it.
  3. Hey how can I search through an XML file for something specific? My XML file has "Customers" which have username and password elements. I need to check if a user exists when registering to ensure there are no duplicates. At the moment I have foreach($xml->customer as $customer) { if ($customer->username=$username) echo 'User exists, please use another username'; else echo 'Username is fine';
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.