Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Excel tabela umesto xml-a?

[es] :: PHP :: Excel tabela umesto xml-a?

[ Pregleda: 2070 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

ivanpro
Beograd

Član broj: 186028
Poruke: 104
*.adsl-4.sezampro.yu.



+10 Profil

icon Excel tabela umesto xml-a?29.05.2009. u 12:57 - pre 181 meseci
Prvo da napomenem da sam pocetnik u ovome...
Da li moze ovde da se umesto .xml fajla prikazuje neka tabela iz excela?

http://www.venustours.rs/ajax1/22.html
Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script type="text/javascript" src="countryStateCity.js"></script>
<script type="text/javascript" src="selectcd.js"></script>
</head>

<body>

<fieldset style="width: 510px;">
<legend><strong>Izaberite Vasu Destinaciju</strong></legend>
<form name="test" method="POST" action="processingpage.php">
<table width="507">
<tr>
<td width="46" style="text-align: left;">Drzava:</td>
<td width="130" style="text-align: left;"><select name="country" id="country" onchange="setStates();">
  <option value="">Izaberite drzavu</option>
  <option value="GRCKA">GRCKA</option>
  <option value="TURSKA">TURSKA</option>
  <option value="EGIPAT">EGIPAT</option>
</select></td>
<td width="34" style="text-align: left;">Grad:</td>
<td width="130" style="text-align: left;"><select name="state" id="state" onchange="setCities();">
  <option value="">Izaberite grad</option>
</select></td>
<td width="33" style="text-align: left;">Hotel</td>
<td width="212" style="text-align: left;"><select name="city"  id="city" onchange="showCD(this.value)">
  <option value="">Izaberite hotel</option>
</select></td>
</tr>
</table>
</form>
<div id="txtHint"><b>CENOVNIK...</b></div>
</fieldset>
</body>
</html>


Code:

<?php
$q=$_GET["q"];

$xmlDoc = new DOMDocument();
$xmlDoc->load("cd_catalog.xml");

$x=$xmlDoc->getElementsByTagName('HOTEL');

for ($i=0; $i<=$x->length-1; $i++)
{
//Process only element nodes
if ($x->item($i)->nodeType==1)
  {
  if ($x->item($i)->childNodes->item(0)->nodeValue == $q)
    {
    $y=($x->item($i)->parentNode);
    }
  }
}

$cd=($y->childNodes);

for ($i=0;$i<$cd->length;$i++)

//Process only element nodes
if ($cd->item($i)->nodeType==1)
  {
  echo($cd->item($i)->nodeName);
  echo(": ");
  echo($cd->item($i)->childNodes->item(0)->nodeValue);
  echo("<br />");
  }
}
?>

Code:


var xmlhttp

function showCD(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="getcd.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)
{
    
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

Code:

var states = new Array();

states['GRCKA'] = new Array('','PARALIJA','PEFKOHORI','ZAKINTOS');
states['TURSKA'] = new Array('','ALANJA','ANTALIJA','KEMER');
states['EGIPAT'] = new Array('','California','Florida','New York');


// City lists
var cities = new Array();

cities['GRCKA'] = new Array();
cities['GRCKA']['']
cities['GRCKA']['PARALIJA']          = new Array('','VILA PARA1','VILA PARA2');
cities['GRCKA']['PEFKOHORI'] = new Array('','VILA PEF1','VILA PEF2');
cities['GRCKA']['ZAKINTOS']          = new Array('','VILA ZAK1','VILA ZAK2');

cities['TURSKA'] = new Array();
cities['TURSKA']['']
cities['TURSKA']['ALANJA'] = new Array('','HOTEL ALANJA1','HOTEL ALANJA2');
cities['TURSKA']['ANTALIJA']       = new Array('','HOTEL ANTALIJA1','HOTEL ANTALIJA2');
cities['TURSKA']['KEMER']         = new Array('','HOTEL KEMER1','HOTEL KEMER2');

cities['EGIPAT'] = new Array();
cities['EGIPAT']['California'] = new Array('','Los Angeles','San Francisco');
cities['EGIPAT']['Florida']    = new Array('','Miami','Orlando');
cities['EGIPAT']['New York']   = new Array('','Buffalo','new York');


function setStates() {
  cntrySel = document.getElementById('country');
  stateList = states[cntrySel.value];
  changeSelect('state', stateList, stateList);
  setCities();
}

function setCities() {
  cntrySel = document.getElementById('country');
  stateSel = document.getElementById('state');
  cityList = cities[cntrySel.value][stateSel.value];
  changeSelect('city', cityList, cityList);
}

function changeSelect(fieldID, newOptions, newValues) {
  selectField = document.getElementById(fieldID);
  selectField.options.length = 0;
  for (i=0; i<newOptions.length; i++) {
    selectField.options[selectField.length] = new Option(newOptions[i], newValues[i]);
  }
}

// Multiple onload function created by: Simon Willison
// http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(function() {
  setStates();
});



[Ovu poruku je menjao Aleksandar Ružičić dana 29.05.2009. u 19:15 GMT+1]
 
Odgovor na temu

Aleksandar Ružičić
Software Architect, Appricot d.o.o.
Beograd

Član broj: 26939
Poruke: 2881

Jabber: krckoorascic@gmail.com
Sajt: krcko.net


+44 Profil

icon Re: Excel tabela umesto xml-a?29.05.2009. u 18:44 - pre 181 meseci
Moguce je da ucitavas podatke iz XLS-a umesto iz XML-a, potrebno je samo da koristis neki od vec postojecih excel readera. Evo neka dva sto je izbacio google:

http://www.phpexcel.net/
http://code.google.com/p/php-excel-reader/
 
Odgovor na temu

ivanpro
Beograd

Član broj: 186028
Poruke: 104
*.adsl-4.sezampro.yu.



+10 Profil

icon Re: Excel tabela umesto xml-a?29.05.2009. u 23:17 - pre 181 meseci
Aleksandre, hvala puno na pomoci. Tako nesto mi je trebalo, samo opet imam problem ?
Ne znam kako i da li uopste moze, da mi na trecem drop-downu otvara drugi .xls koji vazi za tu vrednost.

P.S. Izvinjavam se za promasenu temu.
 
Odgovor na temu

[es] :: PHP :: Excel tabela umesto xml-a?

[ Pregleda: 2070 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.