Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php include_once('Family.php');
- $object = new Family();
- ?>
- <!DOCTYPE HTML>
- <html>
- <head>
- <title>Family Tree</title>
- </head>
- <body>
- <form method="post" action="">
- Child Name: <input type ='text' name ='name' placeholder="Enter name here">
- <select name="parent" id="names" onchange="getSelectValueId()">
- <option>--Select Parent--</option>
- <option id='opt'><?php echo $object->displayParent()?></option>
- </select>
- <input type="submit" name='save' value="Save" hidden="hidden" id='save' >
- <br>
- <input type="submit" name="submit" value="Enter">
- </form>
- <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
- <script>
- /*function changeParent(){
- $(document).ready(function(){
- $("a").click(function() {
- function getEventTarget(e) {
- e = e || window.event;
- return e.target || e.srcElement;
- }
- var ul = document.getElementsByClassName('listSet');
- [].forEach.call(ul, function(el) {
- el.onclick = function(event) {
- var target = getEventTarget(event);
- //alert(target.id);
- document.getElementById('names').value=target.id;
- $("#save").show();
- };
- });
- });
- });
- }*/
- </script>
- <?php
- $object->GetFamilyTree();
- if(isset($_POST['submit'])){
- $name= $_POST["name"];
- $parent= $_POST["parent"];
- $object->enterChild();
- echo "<meta http-equiv='refresh' content='0'>";
- }
- if(isset($_POST['save'])){
- $selected = $_POST['parent'];
- echo "You have selected :" . " " .$selected;
- }
- // var_dump($object->getParentId(4));
- if ($object->getParentId(($_GET['childId']))){
- echo "<script>
- function changeParent(){
- $(document).ready(function(){
- $('a').click(function() {
- $.ajax({
- type: 'GET',
- url: 'http://test.local/Family.php?action=getId',
- data: {'childId' : $_GET[childId]},
- success: function(msg) {
- document.getElementById('names').value = msg;
- }
- });
- });
- });
- }</script>";
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement