943,022 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 293
  • PHP RSS
Aug 4th, 2010
0

multiple ajax calls

Expand Post »
hi all,
i am having a page with date picker. so now when i select a date, images uploaded on that date will be displayed in a table.The date picker will not change,only the below div will change. so now i had a edit button beside date picker.so when i click on edit button those fields in the table should turn into editable way.
Images uploaded on selected date will be displayed,
Now what i need is when i click on edit button that table should turn as editable.
PHP Syntax (Toggle Plain Text)
  1. <?php
  2. @session_start();
  3. echo "<strong style='color:navy'><h2>Welcome $_SESSION[username].</h2></strong>";
  4. ?>
  5. <html>
  6. <script type="text/javascript">
  7. function showUser(str)
  8. {
  9. if (str=="")
  10. {
  11. document.getElementById("txtHint").innerHTML="";
  12. return;
  13. }
  14. if (window.XMLHttpRequest)
  15. {// code for IE7+, Firefox, Chrome, Opera, Safari
  16. xmlhttp=new XMLHttpRequest();
  17. }
  18. else
  19. {// code for IE6, IE5
  20. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  21. }
  22. xmlhttp.onreadystatechange=function()
  23. {
  24. if (xmlhttp.readyState==4 && xmlhttp.status==200)
  25. {
  26. document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
  27. }
  28. }
  29. xmlhttp.open("GET","useajax.php?q="+str,true);
  30. xmlhttp.send();
  31. }
  32.  
  33. </script>
  34. <head>
  35. <link rel="stylesheet" type="text/css" href="css/table.css"/>
  36. <meta charset="UTF-8" />
  37. <link rel="stylesheet" href="css/base.css" type="text/css" media="all" />
  38. <link type="text/css" href="css/jquery.ui.all.css" rel="stylesheet" />
  39. <script type="text/javascript" src="jquery-1.4.2.js"></script>
  40. <script type="text/javascript" src="ui/jquery.ui.core.js"></script>
  41. <script type="text/javascript" src="ui/jquery.ui.widget.js"></script>
  42. <script type="text/javascript" src="ui/jquery.ui.datepicker.js"></script>
  43. <link type="text/css" href="css/demos.css" rel="stylesheet" />
  44. <script type="text/javascript">
  45. $(function() {
  46. $("#datepicker").datepicker();
  47. });
  48. </script>
  49. </head>
  50. <body onload="addRowListeners();">
  51. <form action="imageslist.php" method="post">
  52. <table align="right">
  53. <tr> <td></td>
  54. <td></td><td><a href="logout.php"><h2>Logout</h2></a></td></table>
  55. <div class="demo" align="left">
  56. <h2>Choose Uploaded date <input name="dates" type="text" id="datepicker" onchange="showUser(this.value)">
  57. <input type="button" name="edit" value="Edit" id="edit" style="background-color:#A7C942; color:#ffffff; font-size: 1.2em;"></h2>
  58. </div>
  59. <br>
  60. <div align="center" id="txtHint"><h1>Images information will be listed here.</h1></div>
  61. <table align="center"><tr><td>
  62. </table>
  63. </form>
  64. </body>
  65. </html>
Line 57 is the edit button.
Last edited by niths; Aug 4th, 2010 at 2:17 am.
Similar Threads
Reputation Points: 9
Solved Threads: 2
Posting Whiz in Training
niths is offline Offline
299 posts
since Mar 2010
Aug 4th, 2010
0
Re: multiple ajax calls
You can have multiple ajax requests.
I would suggest using prototype
http://prototypejs.org
it makes it much easier.
use ajax updater to replace the innerhtml with the same content but just put the textarea tags around it.
also wrap it in a wysiwyg editor so as to keep the formatting.
I use openwysiwyg.
you can then change the javascript file to remove the options you don't need.

hope this helps
Reputation Points: 13
Solved Threads: 34
Posting Whiz in Training
metalix is offline Offline
218 posts
since Mar 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: how to remove parse error
Next Thread in PHP Forum Timeline: Storing Passwords Securely in Database and Cookies





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC