Advertisement
Husam1093

Untitled

Jun 13th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. <?php include_once('Family.php');
  2. $object = new Family();
  3. ?>
  4. <!DOCTYPE HTML>
  5. <html>
  6. <head>
  7. <title>Family Tree</title>
  8. </head>
  9. <body>
  10. <form method="post" action="">
  11. Child Name: <input type ='text' name ='name' placeholder="Enter name here">
  12. <select name="parent" id="names" onchange="getSelectValueId()">
  13. <option>--Select Parent--</option>
  14. <option id='opt'><?php echo $object->displayParent()?></option>
  15. </select>
  16. <input type="submit" name='save' value="Save" hidden="hidden" id='save' >
  17. <br>
  18. <input type="submit" name="submit" value="Enter">
  19. </form>
  20.  
  21. <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
  22. <script>
  23.  
  24. /*function changeParent(){
  25. $(document).ready(function(){
  26. $("a").click(function() {
  27. function getEventTarget(e) {
  28. e = e || window.event;
  29. return e.target || e.srcElement;
  30. }
  31. var ul = document.getElementsByClassName('listSet');
  32. [].forEach.call(ul, function(el) {
  33. el.onclick = function(event) {
  34. var target = getEventTarget(event);
  35. //alert(target.id);
  36. document.getElementById('names').value=target.id;
  37. $("#save").show();
  38. };
  39. });
  40. });
  41. });
  42. }*/
  43. </script>
  44.  
  45. <?php
  46. $object->GetFamilyTree();
  47. if(isset($_POST['submit'])){
  48. $name= $_POST["name"];
  49. $parent= $_POST["parent"];
  50. $object->enterChild();
  51. echo "<meta http-equiv='refresh' content='0'>";
  52. }
  53. if(isset($_POST['save'])){
  54. $selected = $_POST['parent'];
  55. echo "You have selected :" . " " .$selected;
  56. }
  57. // var_dump($object->getParentId(4));
  58. if ($object->getParentId(($_GET['childId']))){
  59. echo "<script>
  60. function changeParent(){
  61. $(document).ready(function(){
  62. $('a').click(function() {
  63. $.ajax({
  64. type: 'GET',
  65. url: 'http://test.local/Family.php?action=getId',
  66. data: {'childId' : $_GET[childId]},
  67. success: function(msg) {
  68. document.getElementById('names').value = msg;
  69. }
  70. });
  71. });
  72. });
  73. }</script>";
  74. }
  75.  
  76. ?>
  77. </body>
  78. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement