Jump to content

sirup_segar

Members
  • Posts

    37
  • Joined

  • Last visited

    Never

Everything posted by sirup_segar

  1. hi, after i read php ajax responseXML from w3schools.com, i'd like to try it myself. so i copy-paste the code and have it run from my computer. i use xampp and php5. function showUser(str) { var xmlHttp; xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="responsexml.php" url=url+"?q="+str url=url+"&sid="+Math.random() xmlHttp.onreadystatechange=function() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { xmlDoc=xmlHttp.responseXML; document.getElementById("firstname").innerHTML= xmlDoc.getElementsByTagName("firstname")[0].childNodes[0].nodeValue; document.getElementById("lastname").innerHTML= xmlDoc.getElementsByTagName("lastname")[0].childNodes[0].nodeValue; document.getElementById("job").innerHTML= xmlDoc.getElementsByTagName("job")[0].childNodes[0].nodeValue; document.getElementById("age_text").innerHTML="Age: "; document.getElementById("age").innerHTML= xmlDoc.getElementsByTagName("age")[0].childNodes[0].nodeValue; document.getElementById("hometown_text").innerHTML="<br/>From: "; document.getElementById("hometown").innerHTML= xmlDoc.getElementsByTagName("hometown")[0].childNodes[0].nodeValue; } } xmlHttp.open("GET",url,true) xmlHttp.send(null) } function GetXmlHttpObject() { var objXMLHttp=null if (window.XMLHttpRequest) { objXMLHttp=new XMLHttpRequest() } else if (window.ActiveXObject) { objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP") } return objXMLHttp } and i got error message on my firefox, xmlDoc.getElementsByTagName("firstname")[0].childNodes[0].nodeValue has no properties i'm not familiar with xml, so first i'm confuse in where to post this thread, in ajax room,or else. anyway, this is the php code <?php header('Content-Type: text/xml'); header("Cache-Control: no-cache, must-revalidate"); //A date in the past header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); $q=$_GET["q"]; $con = mysql_connect('localhost', 'peter', 'abc123'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ajax_demo", $con); $sql="SELECT * FROM user WHERE id = ".$q.""; $result = mysql_query($sql); echo '<?xml version="1.0" encoding="ISO-8859-1"?> <person>'; while($row = mysql_fetch_array($result)) { echo "<firstname>" . $row['FirstName'] . "</firstname>"; echo "<lastname>" . $row['LastName'] . "</lastname>"; echo "<age>" . $row['Age'] . "</age>"; echo "<hometown>" . $row['Hometown'] . "</hometown>"; echo "<job>" . $row['Job'] . "</job>"; } echo "</person>"; mysql_close($con); ?> thanks in advance..
  2. sorry mr rajiv, i did it again.. this is my cekqty() function cekqty() { var jml=document.getElementById("max_isbnx").value; for (i=0;i<jml;i++) { var qty=document.getElementById("txt_qty["+i+"]").value; if ((qty<0) || (isNaN(qty)==true)) { alert("Periksa Kembali Inputan Jumlah Buku"); return false; exit; } } return true; } and this is my form <table align='center' width='650' class='mytable'> <tr> <form method='post' action='shop_action.php' name='frmshopaction' onSubmit='return cekqty()'> <td align=center><b>ISBN</b></td> <td align=center><b>Judul</b></td> <td align=center><b>Penerbit</b></td> <td align=center><b>Pengarang</b></td> <td align=center><b>Harga Satuan</b></td> <td align=center><b>Qty</b></td> <td align=center><b>Harga</b></td> </tr> "; $jml=0; $price=0; for ($i=0;$i<$hitung;$i++) { $jml=$jml+$qtyx[$i]; $price=$price+$hrg_qtyx[$i]; } for ($i=0;$i<$hitung;$i++) { $tmpisbn=$isbnx[$i]; $tmpjdul=htmlspecialchars($judulx[$i]); $tmppen=$penerbitx[$i]; $tmppeng=htmlspecialchars($pengarangx[$i]); $tmpqty=$qtyx[$i]; $tmphrg=$hrgx[$i]; $tmphrgtot=$hrg_qtyx[$i]; $hrgrp=tampilrupiah($tmphrg); $hrgtot=tampilrupiah($tmphrgtot); $pricerp=tampilrupiah($price); echo "<tr> <td>$tmpisbn</td> <td>$tmpjdul</td> <td>$tmppen</td> <td>$tmppeng</td> <td>$hrgrp</td> <td><input type='text' name='txt_qty[$i]' id='txt_qty[$i]' value='$tmpqty' size='1'></td> <td>$hrgtot</td> </tr> "; } echo "<tr> <td colspan=8><div class='batalbeli'>Total Barang : <b>$jml</b> ‚ Total Harga : <b>$pricerp</b></div></td> </tr> </table>"; echo "<table align='center'> <tr> <td colspan='3'> <div class='batalbeli'>Untuk membatalkan barang, masukkan angka 0 pada jumlah barang</div> </td> </tr> <tr> <td align='center'> <input type='hidden' id='max_isbnx' value='$hitung'> <input type='image' src='../image/update-qty.gif' height='40' width='150' name='editshop' onClick='cekqty()'> </form> thanks in advance..
  3. mr rajiv,i've solved the problem with my error. i change my code from var qty=document.getElementById("txt_qty"+i); into var qty=document.getElementById("txt_qty["+i+"]").value; and it works, the error dissapear. but another problem come. when i click the submit image <input type='image' src='../image/update-qty.gif' height='40' width='150' name='editshop' onClick='cekqty()'> my form is submitted twice,not only once? so when i try to enter a negative number or non numeric char, the error message from cekqty() displayed twice. ??? thanks a lot..
  4. mr rajiv, thanks for your attention. i've changed my code like you suggest me. function cekqty() { var jml=document.getElementById("max_isbnx").value; for (i=0;i<jml;i++) { var qty=document.getElementById("txt_qty"+i); if ((qty.value<0) || (qty.length==0) || (isNaN(qty)==true)) { alert("Check Your Book Quantity"); return false; } else { return true; } } } anyway, i've changed my form <form method='post' action='shop_action.php' name='frmshopaction' onSubmit='return cekqty()'> apparently the same error message still appear. ???
  5. wow,thanks a lot mr rajiv, that really helps me..cheers..
  6. mr rajiv, how do i put double quotes on my form? because i use echo ""; to display my form. so i change all the double quotes into single quotes..should i change it all? :'(
  7. sorry mr vicodin and mr rajivgonsalves this is my form <form action='shop_additem.php' method='get' name='frmbeli' onSubmit='return cekbeli()'> <table align='right'> <tr> <td> <input type='hidden' name='idisbn' value='$row[1]'> <input type='hidden' name='juduly' value='$judul'> <input type='hidden' name='hargay' value='$tmpharga'> <input type='hidden' name='penerbity' value='$penerbit'> <input type='hidden' name='pengarangy' value='$pengarang'> Jumlah <input type='text' size='1' name='jmlbrgy' maxlength='4'> </td> <td> <input name='submit' type='submit' value='Beli'> </td> </tr> </table> </form> and this is my shop_additem.php if ($jmlbrgy>0) { $isbnx[]=$idisbn; $judulx[]=$juduly; $penerbitx[]=$penerbity; $pengarangx[]=$pengarangy; $qtyx[]=trim($jmlbrgy); $hrgx[]=$hargay; $hrg_qtyx[]=$jmlbrgy*$hargay; } @ mr mmarif4u, my two variables are taken from $penerbit and $pengarang. @mr themistral, i have tried to use addslashes in front of $juduly and $pengarangy on the top of my shop_additem.php. but i got the same result, remaining chars behind apostrophes were still dissapear.. ??? lots of thanks for ur attention..
  8. hi..please give me an advice.. { $judulx[]=$juduly; $pengarangx[]=$pengarangy; } before the form was submitted, the content of $juduly and $pengarangy were "jail house's rock" and "amina ana'akira" respectively. but why after the form was submitted, the variable have changed to "jail house" and "amina ana"? was there something important that i forget? thanks in advance..
  9. hi, still working on my last thread, i found that when i click one of my submit image, <input type='image' src='../image/lihat-katalog.gif' width='150' height='40' name='lihatkat'> <input type='image' src='../image/update-qty.gif' height='40' width='150' name='editshop' onClick='cekqty($count)'> <input type='image' src='../image/selesai-belanja.gif' width='150' height='40' name='cekout'> the same error displayed,just like when i click the <input type='image' src='../image/update-qty.gif' height='40' width='150' name='editshop' onClick='cekqty($count)'> anyway, thanks for your attention..
  10. hi,i've been searching in this forum about my error, but still can't find it out.i try to use regexp to validate number only. function cekqty(n) { var regcek=new RegExp(/^[0-9]+$/); for (i=0;i<n;i++) { var qty=document.getElementById("txt_qty"+i); var qty_ck=qty.value; if ((qty_ck<0) || (qty_ck.length==0) || (qty_ck.search(regcek)<0)) { alert("Check Your Book Quantity"); return false; } else { return true; } } } my form code is : <form method='post' action='shop_action.php' name='frmshopaction' onSubmit='return cekqty($count)'> my td code is : <td><input type='text' name='txt_qty[$i]' id='txt_qty[$i]' value='$tmpqty' size='1'></td> and my submit image is: <input type='hidden' id='max_isbnx' value='$count'> <input type='image' src='../image/update-qty.gif' height='40' width='150' name='editshop' onClick='cekqty($count)'> when i click the image, the error is "object required on line 44 char 3", that is on the "return false" statement. also, the error message displays twice, not only once,with the same error message. lots lots thanks for your help...
  11. i think i'll put "Topics Solved" now..hehe thanks for everyone..
  12. ehmm, by the way again, can we use use multiple header("Location:some_location.php") in some if-else syntax?so there aren't error Warning: Cannot add header information - headers already sent by ? thanks again...i'll give "topics solved" after this thread... thanks;D
  13. for mr PFMaBiSmAd, sorry the answer is no,i didn't change back my form method to post. but i have now, and it worked.thanks a lot. for mr mmarif4u, thanks for the snippet..it's because i haven't change back the method into post.. . by the way, how can i add the "topic solved" flag to my thread??
  14. mr mmarif4u,i have changed my code if (isset($_POST["edit_x"])) { echo "<script language='javascript'> alert('you are edited'); </script>"; } but nothing shows up when i click on the edit image... ???
  15. to andy, yes you're totally right.when i change my form method into 'get', in the address bar i saw weird parameter, like ' http://localhost/pim_update/pengunjung/shop_action.php?txt_qty%5B0%5D=70&txt_qty%5B1%5D=140&lihatkat.x=53&lihatkat.y=20 ' of course i'm confused about what's happen .by the way, i have to change my input type=image's name into 'show_x' and 'show_y', 'edit_x' and 'edit_y', and also 'checkout_x' and 'checkout_y'? or replace the '_x' and 'show_y' with some number? because the value of '_x' and '_y' always changed. thanks a lot bro..
  16. hi,nice to be here again.i think i will often be here hehe i have a form like this <form method='post' action='shop_action.php' name='frmshopaction'> <table align='center' width='650' class='mytable'> <tr> --<tr declaration>-- </tr> "; for ($i=0;$i<$hitung;$i++) { $tmpisbn=$isbnx[$i]; $tmpjdul=$judulx[$i]; $tmppen=$penerbitx[$i]; $tmppeng=$pengarangx[$i]; $tmpqty=$qtyx[$i]; $tmphrg=$hrgx[$i]; $tmphrgtot=$hrg_qtyx[$i]; $hrgrp=tampilrupiah($tmphrg); $hrgtot=tampilrupiah($tmphrgtot); $pricerp=tampilrupiah($price); echo "<tr> <td>$tmpisbn</td> <td>$tmpjdul</td> <td>$tmppen</td> <td>$tmppeng</td> <td>$hrgrp</td> <td><input type='text' name='txt_qty[$i]' id='txt_qty[$i]' value='$tmpqty' size='1'></td> <td>$hrgtot</td> </tr> "; } </table>"; echo "<table align='center'> <tr> <td> <input type='image' src='../image/lihat-katalog.gif' width='150' height='40' name='show'> <input type='image' src='../image/update-qty.gif' height='40' width='150' name='edit'> <input type='image' src='../image/selesai-belanja.gif' width='150' height='40' name='chekout'></td> </tr> </table> </form> and my shop_action.php is below if (isset($_POST["edit"])) { --still working on Edit-- } else if (isset($_POST["show"])) { --still working on show too-- } else if (isset($_POST["chekout"])) { --also,still working on checkout-- when i clik one of my images on frmshopaction,none of my shop_action.php is done. anybody can give me an idea? thanks alot..
  17. the output was "Array () 1" sure i don't know what is that..
  18. hi, i want to upload files to webserver. I use copy($dload,"../pengunjung/download/".stripslashes($dload_name)) is there any other way that i can use? bacause i try to upload a 3,5MB file size, and need about 15 minutes to complete..thanks
  19. i have chmod-ing the file to 775, chmod-ing the download folder (place to save uploaded files) to 775. what else?i'm confused.. ???
  20. but when i use these codes if ($_FILES['dload']['size'] >(10000000)) { ?> <script language="javascript"> alert("Max 10MB!"); </script> <?php to check whether the file size exceeds 10MB, the error occures again. I still use that code that i post recently in this thread. ( check empty uploads) tx again
  21. hi. when i try to upload files, i got these errors Warning: Unable to open '' for reading: Permission denied in c:\apache\htdocs\temporer\administrator\master_download_update.php on line 39 i just want to check whether it's empty or not with this code if (empty($_FILES['dload']['name'])) what's that suppose to mean? ??? thanks
  22. hello..let's get it on . what's the differences between HTML and DHTML? shuold i use HTML or DHTML? thanks..
  23. hi, i'm newbeee in using dreamweaver mx 2004. i wonder, can dreamweaver be used to build like this website? i'm intresting with the banner and the links. cool man. if i just use dreamweaver, coreldraw, phptoshop, can it possible to build like this top-side page including menus? thanks alot..
  24. anybody can explain to me in very simple language: 1. CGI? 2. HTTP? 3. FTP? 4. how to use dreamweaver 8 so we can upload our files into webserver? tx
×
×
  • 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.