Jump to content

dishadcruze

Members
  • Content Count

    45
  • Joined

  • Last visited

Everything posted by dishadcruze

  1. Trying to write a webapp in PHP which works similar to VocalPitchMonitor app (Android) with some added features. But capturing voice and display it as wave format is possible in PHP? Is there any example script for this?
  2. dishadcruze

    Keeping the user active even when the screen is locked

    @ kicken Can i PM my code to you? i have replaced header( "refresh:25...." ); instead of javascript. Still the problem is same. even in mobile also it happens the same.
  3. I have a small online question and answer game. In which once a leader starts games, on particular time duration it goes on till he exits from the game. But when the leader's screen is inactive (both in mobile and laptop as well) / locked, the game stops, it doesn't work. How can i overcome this problem? i have not used cookies so far. is the cookies solve my problem? or any other way please suggest
  4. dishadcruze

    Keeping the user active even when the screen is locked

    Yeah, i am using javascript to submit form to set flag in leader's end like this <script type="text/javascript"> $(function(){ // document.ready function... setTimeout(function(){ $('#FrmID').submit(); },3000); }); </script> And in result page header( "refresh:25;url=play_game.php?id=".$grp_id."" );
  5. dishadcruze

    Keeping the user active even when the screen is locked

    i am using php and mysql. 1. Leader starts the game, a flag is set to 1 in database and players will see the questions (Only this needs Leader's click) 2. After 40 seconds, result will open in leader's side and the result flag will set to 1 and players will see the result. 3. After 40 seconds, it will go back to questions and same thing happens Leader will just starts the game and his work is done. Till he exists the game, it should be running. Here if the leader is inactive , the flag won't set and player have to wait till leader is active. I don't know how to overcome this
  6. I have 2 tbles journal_main and journal_item. in journal main i have fields like id | po_no | period | post_date | vendor 1 | PO123 | 12 | 2018-02-12 | XYZ 2 | PO234 | 12 | 2018-02-13 | ABC in journal_item id | ref_id | type | sku | qty 1 | 1 | poo | A123 | 12 2 | 1 | poo | B234 | 20 3 | 2 | por | A123 | 2 4 | 2 | por | A123 | 3 5 | 2 | por | B234 | 6 i want to get the output as po_no | date | vendor | sku | ordered_qty | received_qty | balance po123 | 2018-02-12 | XYZ | A123 | 12 | 5 | 7 po123 | 2018-02-12 | ABC | B234 | 20 | 6 | 14 i am not getting how to combine 2 queries in a single query. Here i have 2 queries which gives me ordered_qty and received_qty separately for ordered_qty select journal_main.id, journal_main.po_no, journal_main.post_date, journal_main.vendor, journal_item. sku, SUM(journal_item.qty) AS Oqty FROM journal_main INNER JOIN journal_item ON journal_main.id=journal_item.ref_id WHERE journal_item.type='poo' GROUP BY journal_item.sku, journal_main.id for received_qty select journal_main.id, journal_main.po_no, journal_main.post_date, journal_main.vendor, journal_item. sku, SUM(journal_item.qty) AS Rqty FROM journal_main INNER JOIN journal_item ON journal_main.id=journal_item.ref_id WHERE journal_item.type='por' GROUP BY journal_item.sku, journal_main.id
  7. Yup!. Even i tried the same and this the only possible way to get the nearby result as i wanted. Thanks Barand
  8. Now i can't change the method of storing data. how should i solve it then?
  9. @Barand: i tried like this select jm.po_no, jm.vendor, jm.post_date, ji.ref_id, sum(case when ji.type = 'poo' then qty else 0 end) as ordered, sum(case when ji.type = 'por' then qty else 0 end) as received, sum(case when ji.type = 'poo' then qty else - qty end) as total FROM journal_main jm INNER JOIN journal_item ji ON jm.id=ji.ref_id WHERE ji.type IN('poo', 'por') group by jm.id but it returns ordered and received in separate row
  10. dishadcruze

    implementing php long polling

    I want to use php-long polling in my php script to get the instant display of data when admin changes anything from backend. I have browsed for solutions, But could not find any. I have downloaded php-long-polling- master from github. There , i have a file server.php. There the code is like this // PHP caches file data, like requesting the size of a file, by default. clearstatcache() clears that cache clearstatcache(); // get timestamp of when file has been changed the last time $last_change_in_data_file = filemtime($data_source_file); // if no timestamp delivered via ajax or data.txt has been changed SINCE last ajax timestamp if ($last_ajax_call == null || $last_change_in_data_file > $last_ajax_call) { // get content of data.txt $data = file_get_contents($data_source_file); // put data.txt's content and timestamp of last data.txt change into array $result = array( 'data_from_file' => $data, 'timestamp' => $last_change_in_data_file ); // encode to JSON, render the result (for AJAX) $json = json_encode($result); echo $json; // leave this loop step break; } else { // wait for 1 sec (not very sexy as this blocks the PHP/Apache process, but that's how it goes) sleep( 1 ); continue; } } If anything we change in data.txt, it displays as and when in real time. But i am not getting how and where i can add the query or how do i include it in my file. in server.php, it is there like // where does the data come from ? In real world this would be a SQL query or something $data_source_file = 'data.txt'; but where and how can i add sql query? can somebody help me how can i start with or how can i add sql query
  11. dishadcruze

    implementing php long polling

    Can somebody help me out with this?
  12. dishadcruze

    implementing php long polling

    I got the solutions for that. But in my server.php i am displaying a form which will be having few input fields. This should display in #response area. Now i am able to display the same on instant basis. As it loads on seconds basis, i am not able to enter anything on any input boxes. Here is my display page. <?php ob_start(); include('includes/sessions.php'); include('includes/config.php'); include('includes/functions.php'); $grp_id = $_GET['id']; ?> <!DOCTYPE html> <head> <!-- head section --> <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script> <script type="text/javascript"> function getContent(timestamp) { var queryString = {'timestamp' : timestamp, 'id' : <?php echo $grp_id; ?>}; $.ajax( { type: 'GET', url: 'http://localhost/folder/server.php', data: queryString, success: function(data){ // put result data into "obj" var obj = JSON.parse(data); // put the data_from_file into #response $('#response').html(obj.data_from_file); // call the function again, this time with the timestamp we just got from server.php getContent(obj.timestamp); } } ); } // initialize jQuery $(function() { getContent(); }); </script> </head> <body<?php if ($body_classes) { echo ' class="' . $body_classes . '"'; } ?>> <div id="page-content" class="block"> <div class="row gutter30"> <div class="col-xs-12"> <div id="response"></div> <!--Contents in server.php will display according to the condition changes in database--> </div> </div> </div> server.php <?php set_time_limit(0); $data_source_file = 'data.txt'; include('includes/sessions.php'); include('includes/config.php'); include('includes/functions.php'); // main loop while (true) { // if ajax request has send a timestamp, then $last_ajax_call = timestamp, else $last_ajax_call = null $last_ajax_call = isset($_GET['timestamp']) ? (int)$_GET['timestamp'] : null; // PHP caches file data, like requesting the size of a file, by default. clearstatcache() clears that cache // clearstatcache(); // get timestamp of when file has been changed the last time // $last_change_in_data_file = filemtime($data_source_file); // Create database $sql = "SELECT max(gid) FROM base_grp WHERE gid=".$_GET['id'].""; $result = mysqli_query($conn, $sql); $last_change_in_data_file = mysqli_fetch_array($result, MYSQLI_NUM)[0]; // if no timestamp delivered via ajax or data.txt has been changed SINCE last ajax timestamp if ($last_ajax_call == null || $last_change_in_data_file > $last_ajax_call) { $sql = "SELECT is_set FROM base_grp WHERE gid =".$_GET['id'].""; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_assoc($result)) { if($row['is_set'] == 0) { $data .= '<form name="frm" method="post" action="show_data.php"> <div class="row gutter30" style="margin-top:20px;"> <div class="form-group"> <img src="img/img1.png" class="image" /> <input type="text" name="img1" class="form-control" /> <input type="hidden" name="img1_id" value="3" /> </div> <div class="form-group"> <img src="img/img2.png" class="image" /> <input type="text" name="img2" class="form-control" /> <input type="hidden" name="img2_id" value="4" /> </div> <div class="form-group"> <img src="img/img3.png" class="image" /> <input type="text" name="img3" class="form-control" /> <input type="hidden" name="img3_id" value="2" /> </div> <div class="form-group"> <img src="img/img4.png" class="image" /> <input type="text" name="img4" class="form-control" /> <input type="hidden" name="img4_1" value="1" /> </div> <button type="submit" name="lock" class="btn btn-sm btn-success">SUBMIT</button> </div> </form> '; $last_change_in_data_file = $row["gid"]; } else if($row['is_set'] = 1) { $data .= "<div class='row gutter30' style='margin-top:20px;'> <div class='col-xs-3'> <img src='img/img1.png' class='image' /> </div> <div class='col-xs-3'> <img src='img/img2.png' class='image' /> </div> <div class='col-xs-3'> <img src='img/img3.png' class='image' /> </div> <div class='col-xs-3'> <img src='img/img4.png' class='image' /> </div> </div> "; $last_change_in_data_file = $row["gid"]; } $last_change_in_data_file = $row["gid"]; } } // mysqli_close($conn); // put data.txt's content and timestamp of last data.txt change into array $result = array( 'data_from_file' => $data, 'timestamp' => $last_change_in_data_file ); mysqli_close($conn); // encode to JSON, render the result (for AJAX) $json = json_encode($result); echo $json; // leave this loop step break; } else { // wait for 1 sec (not very sexy as this blocks the PHP/Apache process, but that's how it goes) sleep( 1 ); continue; } } I tried adding delay of 20 seconds in function like this $(function() { setTimeout("getContent();",20000); }); But for 1st time also it takes 20 secs to display data. Can somebody suggest me where i am going wrong?
  13. dishadcruze

    implementing php long polling

    @ mac_gyver My exact scenario is: There is a group A formed by a user User1 and in that group there will be minimum 4 members. When minimum 4 members are online, group owner (User1) will updates some queries on db and he will hit a button 'OK'. When he hits the button , a filed in database sets 1. When this sets to 1, all the online users of this group gets the notification about this. And for them approve button will be activated. Once they approve its immediately visible to admin that who all approved. I am doing it with php-long-polling. But here i am not getting how exactly i can use this to my requirement. I just need some hints and direction. Can you please guide me how can i go with this along with php long polling. I am not comfortable in java-scripts so i am using this.
  14. dishadcruze

    implementing php long polling

    Yes even i want to display the record according to 'last_id' but i can query in sql and php , but my only problem is to display as and when it updated. Here i stuck
  15. dishadcruze

    implementing php long polling

    basically i want to pass a variable to this page along with timestamp. Timestamp is getting passed like this in client.js timestamp is getting passed like this function getContent(timestamp) { var queryString = {'timestamp' : timestamp}; $.ajax( { type: 'GET', url: 'http://localhost/php-long-polling/server/server.php', data: queryString, success: function(data){ // put result data into "obj" var obj = jQuery.parseJSON(data); // put the data_from_file into #response $('#response').html(obj.data_from_file); // call the function again, this time with the timestamp we just got from server.php getContent(obj.timestamp); } } ); } // initialize jQuery $(function() { getContent(); }); so here i am not getting how to do it
  16. dishadcruze

    implementing php long polling

    No, what i meant was, how to send that 'id' through url or post to this page??
  17. dishadcruze

    implementing php long polling

    After many attempts i could do it like this in server.php, i did like this <?php /** * Server-side file. * This file is an infinitive loop. Seriously. * It gets the file data.txt's last-changed timestamp, checks if this is larger than the timestamp of the * AJAX-submitted timestamp (time of last ajax request), and if so, it sends back a JSON with the data from * data.txt (and a timestamp). If not, it waits for one seconds and then start the next while step. * * Note: This returns a JSON, containing the content of data.txt and the timestamp of the last data.txt change. * This timestamp is used by the client's JavaScript for the next request, so THIS server-side script here only * serves new content after the last file change. Sounds weird, but try it out, you'll get into it really fast! */ // set php runtime to unlimited set_time_limit(0); // where does the data come from ? In real world this would be a SQL query or something $data_source_file = 'data.txt'; $servername = "localhost"; $username = "*****"; $password = "******"; $dbname = "mydb"; // Create connection $conn = mysqli_connect($servername, $username, $password , $dbname); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } // main loop while (true) { // if ajax request has send a timestamp, then $last_ajax_call = timestamp, else $last_ajax_call = null $last_ajax_call = isset($_GET['timestamp']) ? (int)$_GET['timestamp'] : null; // PHP caches file data, like requesting the size of a file, by default. clearstatcache() clears that cache // clearstatcache(); // get timestamp of when file has been changed the last time // $last_change_in_data_file = filemtime($data_source_file); // Create database $sql = "SELECT max(tax_id) FROM taxes"; $result = mysqli_query($conn, $sql); $last_change_in_data_file = mysqli_fetch_array($result, MYSQLI_NUM)[0]; // if no timestamp delivered via ajax or data.txt has been changed SINCE last ajax timestamp if ($last_ajax_call == null || $last_change_in_data_file > $last_ajax_call) { // get content of data.txt // $data = file_get_contents($data_source_file); // Create database $sql = "SELECT tax_id, name FROM taxes"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_assoc($result)) { $data .= "id: " . $row["tax_id"]. " - Name: " . $row["name"]. "<br>"; $last_change_in_data_file = $row["id"]; } } // mysqli_close($conn); // put data.txt's content and timestamp of last data.txt change into array $result = array( 'data_from_file' => $data, 'timestamp' => $last_change_in_data_file ); mysqli_close($conn); // encode to JSON, render the result (for AJAX) $json = json_encode($result); echo $json; // leave this loop step break; } else { // wait for 1 sec (not very sexy as this blocks the PHP/Apache process, but that's how it goes) sleep( 1 ); continue; } } But i want to get the data according to particular id. my sql statement has to be something like this $sql = "SELECT tax_id, name FROM taxes WHERE grp_id=".$id.""; So i am not getting from where i should pass the id to this page Can somebody help me in this??
  18. I want to convert my dropdown to ajax auto search. Here is my dropdown, when i select any company name it displays other 2 dropdowns by taking the id. <select name="company" class="form-control" onChange="showSubcat(this);" required> <option value="">Select Company</option> <?php $s1 = mysqli_query($con, "select * from company") or die (mysqli_error($con)); while($s2 = mysqli_fetch_array($s1)) { ?> <option value="<?php echo $s2['id']; ?>"><?php echo $s2['company']; ?></option> <?php } ?> </select> In showSubcat(), i display 2 dropdowns from database. As i have huge company names stored in database, its difficult to select from dropdown , so i want to convert this into ajax auto search. I tried to do like this <input type="text" name="company" class="typeahead tt-query" autocomplete="off" spellcheck="false" placeholder="Company Name"> Here i am facing 2 issues This is taking company name , but i want to take company id so that i can display other 2 dropdowns Not getting how to display 2 drop down based on this value, not getting how to call onChange()
  19. While adding line items in invoice, i am trying to give product description in ckeditor editable form. But the editor is showing only for 1st product. Here is the code <table class="table table-bordered"> <tr> <th><input class='check_all' type='checkbox' onclick="select_all()"/></th> <th>Name</th> <th>Description</th> <!-- Other heading like qty,tax...etc --> </tr> <tr> <td><input type='checkbox' class='case'/></td> <td><input type="text" class="form-control" id="productname_1" name="productname[]" style="width:120px;"></td> <td><textarea class="editor form-control" id="description_1" name="description[]"></textarea></td> <!---other input values --> <td><button type="button" class='btn btn-danger delete'>-</button></td> <td><button type="button" class='btn btn-success addmore'>+ </button></td> </tr></table> Through jquery i add as many as products . my add.js goes like this $(".delete").on('click', function() { $('.case:checkbox:checked').parents("tr").remove(); $('.check_all').prop("checked", false); check(); }); var i = $('table tr').length - 1; $(".addmore").on('click', function() { count = $('table tr').length - 1; var data = "<tr><td><input type='checkbox' class='case'/></td><td><input class='form-control' type='text' style='width:120px;' id='productname_" + i + "' name='productname[]'/></td><td><textarea class='editor form-control' id='description_"+ i + "' name='description[]' ></textarea></td></tr>"; I add editor like this within <head> </head> <script src="../assets/ckeditor/ckeditor.js" type="text/javascript"></script> <script type="text/javascript" src="../assets/ckeditor/adapters/jquery.js"></script> <script type="text/javascript"> $(function(){ $('.editor').ckeditor(); }); </script>
  20. dishadcruze

    Adding ckeditor for dynamically generated rows

    @requinix : Can you please explain more? sorry, i did not get
  21. i am checking whether the logged in user has access to the page he is trying to view through a script. I have a table pages where i store page ids with links like this and in a table access_level i store user's access now if a user clicks on delete button echo "<td><a onClick=\"javascript: return confirm('Please confirm deletion');\" href='delete_lead.php?id=".$row['LID']."'><div class='label label-danger'><i class='fa fa-trash' title='Delete'></i></div></a></td> "; he should not be able to delete but he should be redirected to no_access.php. This is working file for all other files except delete file. my delete file is like this include('../access.php'); $id = $_GET['id']; $sql = mysqli_query($con, "delete from leads where id=".$id."") or die (mysqli_error($con)); if($sql) { header("location:leads_view.php"); } My access checking file is like this <?php ob_start(); include("connect.php"); include("admin_auth.php"); $q1 = basename($_SERVER['REQUEST_URI'], '?' . $_SERVER['QUERY_STRING']); $q2 = $_SERVER['REQUEST_URI']; $var1 = "/".$q1; $qa_path=explode('/', $q2); $right_path = $qa_path[2].$var1; $parsedUrl = parse_url($q2); $curdir = dirname($_SERVER['REQUEST_URI'])."/"; $l1 = "select teams from team_members WHERE user_id=".$_SESSION['user_id']." "; $l2 = mysqli_query($con, $l1) or die(mysqli_error($con)); $cnt = mysqli_num_rows($l2); if($cnt>0) { $l3 = mysqli_fetch_array($l2); $teams = $l3['teams']; $m1 = "select pages.page_id, pages.code, pages.page, pages.href, access_level.aid, access_level.page_id, access_level.user_id FROM pages INNER JOIN access_level ON pages.page_id=access_level.page_id WHERE access_level.user_id=".$_SESSION['user_id']." OR access_level.user_id IN('".$teams."')"; $m2 = mysqli_query($con, $m1) or die (mysqli_error($con)); while($nk = mysqli_fetch_array($m2)) { $href[] = ($nk['href']); } if(in_array($right_path, $href)) { echo "<script type='text/javascript'> document.location = ".BASE_URL."/".$right_path."</script>"; } else { echo "<script type='text/javascript'> document.location = '../no_access.php' </script>"; } } else if($cnt==0) { $m1 = "select pages.page_id, pages.code, pages.page, pages.href, access_level.aid, access_level.page_id, access_level.user_id FROM pages INNER JOIN access_level ON pages.page_id=access_level.page_id WHERE access_level.user_id=".$_SESSION['user_id'].""; $m2 = mysqli_query($con, $m1) or die (mysqli_error($con)); while($nk = mysqli_fetch_array($m2)) { $href[] = ($nk['href']); } if(in_array($right_path, $href)) { echo "<script type='text/javascript'> document.location = ".BASE_URL."/".$right_path."</script>"; } else { echo "<script type='text/javascript'> document.location = '../no_access.php' </script>"; } } record is getting deleted , not getting why
  22. This is related to https://forums.phpfreaks.com/topic/303946-auto-calculation-not-happening-for-dynamic-rows/ I have added few other columns to have detailed calculations. While editing my calculations are not happening. Here it is Javascript $(".delete").on('click', function() { $('.case:checkbox:checked').parents("tr").remove(); $('.check_all').prop("checked", false); check(); }); var i = $('table tr').length - 1; $(".addmore").on('click', function() { count = $('table tr').length - 1; var data = "<tr><td><input type='checkbox' class='case'/></td><td><input class='form-control' type='text' id='productcode_" + i + "' name='productcode[]'/></td> <td><textarea class='form-control' id='description_"+ i + "' name='description[]'></textarea></td><td><select class='form-control uom' id='uom_" + i + "' name='uom[]'><option value=''>UOM</option>" + options1 + "</select></td><td><input class='form-control price' type='text' id='price_" + i + "' name='price[]'/></td><td><select class='form-control tax' id='tax_" + i + "' name='tax[]'><option value=''>Tax</option>" + options + "</select></select></td><td><input class='form-control quantity' type='text' id='quantity_" + i + "' name='quantity[]'/></td><td><input class='form-control discount' type='text' id='discount_" + i + "' name='discount[]'/></td><td><input class='form-control amount' type='text' id='amount_" + i + "' name='amount[]'/></td><td><input class='form-control tamount' type='text' id='tamount_" + i + "' name='tamount[]'/></td></tr>"; $('table').append(data); row = i; $('#productcode_' + i).autocomplete({ source: function(request, response) { $.ajax({ url: 'ajax.php', dataType: "json", method: 'post', data: { name_startsWith: request.term, type: 'items_table', row_num: row }, success: function(data) { response($.map(data, function(item) { var code = item.split("|"); return { label: code[0], value: code[0], data: item } })); } }); }, autoFocus: true, minLength: 0, select: function(event, ui) { var names = ui.item.data.split("|"); id_arr = $(this).attr('id'); id = id_arr.split("_"); $('#description_' + id[1]).val(names[1]); $('#uom_' + id[1]).val(names[2]); $('#price_' + id[1]).val(names[3]); $('#tax' + id[1]).val(names[4]); } }); i++; }); function select_all() { $('input[class=case]:checkbox').each(function() { if ($('input[class=check_all]:checkbox:checked').length == 0) { $(this).prop("checked", false); } else { $(this).prop("checked", true); } }); } $('body').on('change', '.quantity,.price,.discount,.tax', function() { var tr = $(this).parent().parent(); var qty = tr.find('.quantity').val(); var price = tr.find('.price').val(); var tax = tr.find('.tax').val(); var dis = tr.find('.discount').val(); var amt = (qty * price) - (qty * price * dis) / 100; var tax1 = (amt * (tax / 100)); tax1 = Number((tax1).toFixed(2)); tr.find('.tamount').val(tax1); ttotal(); tr.find('.amount').val(amt); total(); tr.find('.ttotal').val(amt); ttotal1(); }); function total() { var t = 0; $('.amount').each(function(i, e) { var amt = $(this).val() - 0; t += amt; t = Number((t).toFixed(2)); }); $('.total').html(t); } function ttotal() { var tt = 0; $('.tamount').each(function(i, e) { var tax = $(this).val() - 0; tt += tax; tt = Number((tt).toFixed(2)); }); $('.ttotal').html(tt); } function ttotal1() { var ttt = 0; var ty1 = tr.find('.total').val(); var ty2 = tr.find('.ttotal').val(); ttt = ty1+ty2; ttt = Number((ttt).toFixed(2)); $('.ttotal1').html(ttt); } function check() { obj = $('table tr').find('span'); $.each(obj, function(key, value) { id = value.id; $('#' + id).html(key + 1); }); } $('#productcode_1').autocomplete({ source: function(request, response) { $.ajax({ url: 'ajax.php', dataType: "json", method: 'post', data: { name_startsWith: request.term, type: 'items_table', row_num: 1 }, success: function(data) { response($.map(data, function(item) { var code = item.split("|"); return { label: code[0], value: code[0], data: item } })); } }); }, autoFocus: true, minLength: 0, select: function(event, ui) { var names = ui.item.data.split("|"); $('#description_1').val(names[1]); $('#uom_1').val(names[2]); $('#price_1').val(names[3]); $('#tax_1').val(names[4]); } }); Html <table class="table table-bordered"> <tr> <th><input class='check_all' type='checkbox' onclick="select_all()"/></th> <th>Item ID</th> <th>Description</th> <th>UOM</th> <th>Price</th> <th>Tax</th> <th>Quantity</th> <th>Discount</th> <th>Amount</th> <th>Tax Amount</th> </tr> //mysqli query and while loop { <tr> <td><input type="checkbox" name="selector[]" value="<?php echo $row1['id'];?>" class="case" /></td> <td><input type="text" class="form-control" id="productcode_1" name="productcode[<?php echo $row1['id'];?>]" value="<?php echo $row1['iid']; ?>" readonly="readonly" /></td> <td><textarea class="form-control" id="description_1" name="description[<?php echo $row1['id'];?>]"><?php echo $row1['description']; ?></textarea></td> <td><select name="uom[<?php echo $row1['id'];?>]" class="form-control" id="uom_1" style="width:80px"> <option value="<?php echo $row1['uom']; ?>"><?php echo $row1['uom']; ?></option> <?php $su1 = mysqli_query($con, "select * from uom"); while($su2 = mysqli_fetch_array($su1)) { ?> <option value="<?php echo $su2['uom_name']; ?>"><?php echo $su2['uom_name']; ?></option> <?php } ?> </select> </td> <td><input type="text" class="form-control price" id="price_1" value="<?php echo $row1['selling_price']; ?>" name="price[<?php echo $row1['id']; ?>]"></td> <td><select name="tax[<?php echo $row1['id'];?>]" class="form-control tax" id="tax_1" style="width:80px"> <option value="<?php echo $row1['rate']; ?>"><?php echo $row1['tname']; ?></option> <?php $s1 = mysqli_query($con, "select * from taxes"); while($s2 = mysqli_fetch_array($s1)) { ?> <option value="<?php echo $s2['rate']; ?>"><?php echo $s2['name']; ?></option> <?php } ?> </select> </td> <td><input type="text" class="form-control quantity" value="<?php echo $row1['quantity']; ?>" id="quantity_1" name="quantity[<?php echo $row1['id'];?>]"></td> <td><input type="text" class="form-control discount" id="discount_1" value="<?php echo $row1['discount']; ?>" name="discount[<?php echo $row1['id'];?>]"></td> <td><input type="text" class="form-control amount" id="amount_1" value="<?php echo $row1['Total']; ?>" name="amount[<?php echo $row1['id'];?>]"></td> <td><input type="text" class="form-control tamount" id="tamount_1" value="<?php echo $row1['tax_amount']; ?>" name="tamount[<?php echo $row1['id']; ?>]"></td> <td><a href="delete_quote_item.php?id=<?php echo $row1['id']?>&& order_id=<?php echo $order_id?>" onclick="return confirm('Are you sure you want to delete this item?');"><img src="images/remove.png" /></a></td> </tr> <?php $total_amt += $row1['Total']; $tax_amt += $row1['tax_amount']; } ?> <tr> <th></th> <th></th> <th></th> <th></th> <th></th> <th></th> <th>Sub-Total</th> <th style="text-align:center;" class="total" id="total"><?php echo number_format($total_amt,2); ?><b></b></th> <th style="text-align:center;" class="ttotal" id="ttotal"><?php echo number_format($tax_amt,2); ?><b></b></th> <th style="text-align:center;" class="ttotal1" id="ttotal1"><?php echo number_format(($total_amt+$tax_amt),2); ?><b></b></th> </tr> // while loop ends } I want to display total_amt+tax_amt result in tttoal1 <td> As it is edit, 1st time it is getting displayed, if i change anything (quantity, tax, price) grand total is not getting calculated. function tttotal1() is not working
  23. dishadcruze

    summing two variables which has been added dynamically

    these are the plugin i have included <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script> <script type="text/javascript" src="js/jquery-ui.min.js"></script> 1st one i have included in fiddle, 2nd one i am not able to include there so here i am pasting (jquery-ui.min.js) /*! jQuery UI - v1.11.2 - 2014-12-09 * http://jqueryui.com * Includes: core.js, widget.js, position.js, autocomplete.js, menu.js * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */ (function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e(jQuery)})(function(e){function t(t,s){var n,a,o,r=t.nodeName.toLowerCase();return"area"===r?(n=t.parentNode,a=n.name,t.href&&a&&"map"===n.nodeName.toLowerCase()?(o=e("img[usemap='#"+a+"']")[0],!!o&&i(o)):!1):(/input|select|textarea|button|object/.test(r)?!t.disabled:"a"===r?t.href||s:s)&&i(t)}function i(t){return e.expr.filters.visible(t)&&!e(t).parents().addBack().filter(function(){return"hidden"===e.css(this,"visibility")}).length}e.ui=e.ui||{},e.extend(e.ui,{version:"1.11.2",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),e.fn.extend({scrollParent:function(t){var i=this.css("position"),s="absolute"===i,n=t?/(auto|scroll|hidden)/:/(auto|scroll)/,a=this.parents().filter(function(){var t=e(this);return s&&"static"===t.css("position")?!1:n.test(t.css("overflow")+t.css("overflow-y")+t.css("overflow-x"))}).eq(0);return"fixed"!==i&&a.length?a:e(this[0].ownerDocument||document)},uniqueId:function(){var e=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++e)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&e(this).removeAttr("id")})}}),e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(i){return!!e.data(i,t)}}):function(t,i,s){return!!e.data(t,s[3])},focusable:function(i){return t(i,!isNaN(e.attr(i,"tabindex")))},tabbable:function(i){var s=e.attr(i,"tabindex"),n=isNaN(s);return(n||s>=0)&&t(i,!n)}}),e("<a>").outerWidth(1).jquery||e.each(["Width","Height"],function(t,i){function s(t,i,s,a){return e.each(n,function(){i-=parseFloat(e.css(t,"padding"+this))||0,s&&(i-=parseFloat(e.css(t,"border"+this+"Width"))||0),a&&(i-=parseFloat(e.css(t,"margin"+this))||0)}),i}var n="Width"===i?["Left","Right"]:["Top","Bottom"],a=i.toLowerCase(),o={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+i]=function(t){return void 0===t?o["inner"+i].call(this):this.each(function(){e(this).css(a,s(this,t)+"px")})},e.fn["outer"+i]=function(t,n){return"number"!=typeof t?o["outer"+i].call(this,t):this.each(function(){e(this).css(a,s(this,t,!0,n)+"px")})}}),e.fn.addBack||(e.fn.addBack=function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}),e("<a>").data("a-b","a").removeData("a-b").data("a-b")&&(e.fn.removeData=function(t){return function(i){return arguments.length?t.call(this,e.camelCase(i)):t.call(this)}}(e.fn.removeData)),e.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),e.fn.extend({focus:function(t){return function(i,s){return"number"==typeof i?this.each(function(){var t=this;setTimeout(function(){e(t).focus(),s&&s.call(t)},i)}):t.apply(this,arguments)}}(e.fn.focus),disableSelection:function(){var e="onselectstart"in document.createElement("div")?"selectstart":"mousedown";return function(){return this.bind(e+".ui-disableSelection",function(e){e.preventDefault()})}}(),enableSelection:function(){return this.unbind(".ui-disableSelection")},zIndex:function(t){if(void 0!==t)return this.css("zIndex",t);if(this.length)for(var i,s,n=e(this[0]);n.length&&n[0]!==document;){if(i=n.css("position"),("absolute"===i||"relative"===i||"fixed"===i)&&(s=parseInt(n.css("zIndex"),10),!isNaN(s)&&0!==s))return s;n=n.parent()}return 0}}),e.ui.plugin={add:function(t,i,s){var n,a=e.ui[t].prototype;for(n in s)a.plugins[n]=a.plugins[n]||[],a.plugins[n].push([i,s[n]])},call:function(e,t,i,s){var n,a=e.plugins[t];if(a&&(s||e.element[0].parentNode&&11!==e.element[0].parentNode.nodeType))for(n=0;a.length>n;n++)e.options[a[n][0]]&&a[n][1].apply(e.element,i)}};var s=0,n=Array.prototype.slice;e.cleanData=function(t){return function(i){var s,n,a;for(a=0;null!=(n=i[a]);a++)try{s=e._data(n,"events"),s&&s.remove&&e(n).triggerHandler("remove")}catch(o){}t(i)}}(e.cleanData),e.widget=function(t,i,s){var n,a,o,r,h={},l=t.split(".")[0];return t=t.split(".")[1],n=l+"-"+t,s||(s=i,i=e.Widget),e.expr[":"][n.toLowerCase()]=function(t){return!!e.data(t,n)},e[l]=e[l]||{},a=e[l][t],o=e[l][t]=function(e,t){return this._createWidget?(arguments.length&&this._createWidget(e,t),void 0):new o(e,t)},e.extend(o,a,{version:s.version,_proto:e.extend({},s),_childConstructors:[]}),r=new i,r.options=e.widget.extend({},r.options),e.each(s,function(t,s){return e.isFunction(s)?(h[t]=function(){var e=function(){return i.prototype[t].apply(this,arguments)},n=function(e){return i.prototype[t].apply(this,e)};return function(){var t,i=this._super,a=this._superApply;return this._super=e,this._superApply=n,t=s.apply(this,arguments),this._super=i,this._superApply=a,t}}(),void 0):(h[t]=s,void 0)}),o.prototype=e.widget.extend(r,{widgetEventPrefix:a?r.widgetEventPrefix||t:t},h,{constructor:o,namespace:l,widgetName:t,widgetFullName:n}),a?(e.each(a._childConstructors,function(t,i){var s=i.prototype;e.widget(s.namespace+"."+s.widgetName,o,i._proto)}),delete a._childConstructors):i._childConstructors.push(o),e.widget.bridge(t,o),o},e.widget.extend=function(t){for(var i,s,a=n.call(arguments,1),o=0,r=a.length;r>o;o++)for(i in a[o])s=a[o][i],a[o].hasOwnProperty(i)&&void 0!==s&&(t[i]=e.isPlainObject(s)?e.isPlainObject(t[i])?e.widget.extend({},t[i],s):e.widget.extend({},s):s);return t},e.widget.bridge=function(t,i){var s=i.prototype.widgetFullName||t;e.fn[t]=function(a){var o="string"==typeof a,r=n.call(arguments,1),h=this;return a=!o&&r.length?e.widget.extend.apply(null,[a].concat(r)):a,o?this.each(function(){var i,n=e.data(this,s);return"instance"===a?(h=n,!1):n?e.isFunction(n[a])&&"_"!==a.charAt(0)?(i=n[a].apply(n,r),i!==n&&void 0!==i?(h=i&&i.jquery?h.pushStack(i.get()):i,!1):void 0):e.error("no such method '"+a+"' for "+t+" widget instance"):e.error("cannot call methods on "+t+" prior to initialization; "+"attempted to call method '"+a+"'")}):this.each(function(){var t=e.data(this,s);t?(t.option(a||{}),t._init&&t._init()):e.data(this,s,new i(a,this))}),h}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(t,i){i=e(i||this.defaultElement||this)[0],this.element=e(i),this.uuid=s++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=e(),this.hoverable=e(),this.focusable=e(),i!==this&&(e.data(i,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===i&&this.destroy()}}),this.document=e(i.style?i.ownerDocument:i.document||i),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(t,i){var s,n,a,o=t;if(0===arguments.length)return e.widget.extend({},this.options);if("string"==typeof t)if(o={},s=t.split("."),t=s.shift(),s.length){for(n=o[t]=e.widget.extend({},this.options[t]),a=0;s.length-1>a;a++)n[s[a]]=n[s[a]]||{},n=n[s[a]];if(t=s.pop(),1===arguments.length)return void 0===n[t]?null:n[t];n[t]=i}else{if(1===arguments.length)return void 0===this.options[t]?null:this.options[t];o[t]=i}return this._setOptions(o),this},_setOptions:function(e){var t;for(t in e)this._setOption(t,e[t]);return this},_setOption:function(e,t){return this.options[e]=t,"disabled"===e&&(this.widget().toggleClass(this.widgetFullName+"-disabled",!!t),t&&(this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus"))),this},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_on:function(t,i,s){var n,a=this;"boolean"!=typeof t&&(s=i,i=t,t=!1),s?(i=n=e(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),e.each(s,function(s,o){function r(){return t||a.options.disabled!==!0&&!e(this).hasClass("ui-state-disabled")?("string"==typeof o?a[o]).apply(a,arguments):void 0}"string"!=typeof o&&(r.guid=o.guid=o.guid||r.guid||e.guid++);var h=s.match(/^([\w:-]*)\s*(.*)$/),l=h[1]+a.eventNamespace,u=h[2];u?n.delegate(u,l,r):i.bind(l,r)})},_off:function(t,i){i=(i||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,t.unbind(i).undelegate(i),this.bindings=e(this.bindings.not(t).get()),this.focusable=e(this.focusable.not(t).get()),this.hoverable=e(this.hoverable.not(t).get())},_delay:function(e,t){function i(){return("string"==typeof e?s[e]:e).apply(s,arguments)}var s=this;return setTimeout(i,t||0)},_hoverable:function(t){this.hoverable=this.hoverable.add(t),this._on(t,{mouseenter:function(t){e(t.currentTarget).addClass("ui-state-hover")},mouseleave:function(t){e(t.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(t){this.focusable=this.focusable.add(t),this._on(t,{focusin:function(t){e(t.currentTarget).addClass("ui-state-focus")},focusout:function(t){e(t.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(t,i,s){var n,a,o=this.options[t];if(s=s||{},i=e.Event(i),i.type=(t===this.widgetEventPrefix?t:this.widgetEventPrefix+t).toLowerCase(),i.target=this.element[0],a=i.originalEvent)for(n in a)n in i||(i[n]=a[n]);return this.element.trigger(i,s),!(e.isFunction(o)&&o.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},e.each({show:"fadeIn",hide:"fadeOut"},function(t,i){e.Widget.prototype["_"+t]=function(s,n,a){"string"==typeof n&&(n={effect:n});var o,r=n?n===!0||"number"==typeof n?i:n.effect||i:t;n=n||{},"number"==typeof n&&(n={duration:n}),o=!e.isEmptyObject(n),n.complete=a,n.delay&&s.delay(n.delay),o&&e.effects&&e.effects.effect[r]?s[t](n):r!==t&&s[r]?s[r](n.duration,n.easing,a):s.queue(function(i){e(this)[t](),a&&a.call(s[0]),i()})}}),e.widget,function(){function t(e,t,i){return[parseFloat(e[0])*(p.test(e[0])?t/100:1),parseFloat(e[1])*(p.test(e[1])?i/100:1)]}function i(t,i){return parseInt(e.css(t,i),10)||0}function s(t){var i=t[0];return 9===i.nodeType?{width:t.width(),height:t.height(),offset:{top:0,left:0}}:e.isWindow(i)?{width:t.width(),height:t.height(),offset:{top:t.scrollTop(),left:t.scrollLeft()}}:i.preventDefault?{width:0,height:0,offset:{top:i.pageY,left:i.pageX}}:{width:t.outerWidth(),height:t.outerHeight(),offset:t.offset()}}e.ui=e.ui||{};var n,a,o=Math.max,r=Math.abs,h=Math.round,l=/left|center|right/,u=/top|center|bottom/,d=/[\+\-]\d+(\.[\d]+)?%?/,c=/^\w+/,p=/%$/,f=e.fn.position;e.position={scrollbarWidth:function(){if(void 0!==n)return n;var t,i,s=e("<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>"),a=s.children()[0];return e("body").append(s),t=a.offsetWidth,s.css("overflow","scroll"),i=a.offsetWidth,t===i&&(i=s[0].clientWidth),s.remove(),n=t-i},getScrollInfo:function(t){var i=t.isWindow||t.isDocument?"":t.element.css("overflow-x"),s=t.isWindow||t.isDocument?"":t.element.css("overflow-y"),n="scroll"===i||"auto"===i&&t.width<t.element[0].scrollWidth,a="scroll"===s||"auto"===s&&t.height<t.element[0].scrollHeight;return{width:a?e.position.scrollbarWidth():0,height:n?e.position.scrollbarWidth():0}},getWithinInfo:function(t){var i=e(t||window),s=e.isWindow(i[0]),n=!!i[0]&&9===i[0].nodeType;return{element:i,isWindow:s,isDocument:n,offset:i.offset()||{left:0,top:0},scrollLeft:i.scrollLeft(),scrollTop:i.scrollTop(),width:s||n?i.width():i.outerWidth(),height:s||n?i.height():i.outerHeight()}}},e.fn.position=function(n){if(!n||!n.of)return f.apply(this,arguments);n=e.extend({},n);var p,m,g,v,y,b,_=e(n.of),x=e.position.getWithinInfo(n.within),w=e.position.getScrollInfo(x),k=(n.collision||"flip").split(" "),T={};return b=s(_),_[0].preventDefault&&(n.at="left top"),m=b.width,g=b.height,v=b.offset,y=e.extend({},v),e.each(["my","at"],function(){var e,t,i=(n[this]||"").split(" ");1===i.length&&(i=l.test(i[0])?i.concat(["center"]):u.test(i[0])?["center"].concat(i):["center","center"]),i[0]=l.test(i[0])?i[0]:"center",i[1]=u.test(i[1])?i[1]:"center",e=d.exec(i[0]),t=d.exec(i[1]),T[this]=[e?e[0]:0,t?t[0]:0],n[this]=[c.exec(i[0])[0],c.exec(i[1])[0]]}),1===k.length&&(k[1]=k[0]),"right"===n.at[0]?y.left+=m:"center"===n.at[0]&&(y.left+=m/2),"bottom"===n.at[1]?y.top+=g:"center"===n.at[1]&&(y.top+=g/2),p=t(T.at,m,g),y.left+=p[0],y.top+=p[1],this.each(function(){var s,l,u=e(this),d=u.outerWidth(),c=u.outerHeight(),f=i(this,"marginLeft"),b=i(this,"marginTop"),D=d+f+i(this,"marginRight")+w.width,S=c+b+i(this,"marginBottom")+w.height,N=e.extend({},y),M=t(T.my,u.outerWidth(),u.outerHeight());"right"===n.my[0]?N.left-=d:"center"===n.my[0]&&(N.left-=d/2),"bottom"===n.my[1]?N.top-=c:"center"===n.my[1]&&(N.top-=c/2),N.left+=M[0],N.top+=M[1],a||(N.left=h(N.left),N.top=h(N.top)),s={marginLeft:f,marginTop:b},e.each(["left","top"],function(t,i){e.ui.position[k[t]]&&e.ui.position[k[t]][i](N,{targetWidth:m,targetHeight:g,elemWidth:d,elemHeight:c,collisionPosition:s,collisionWidth:D,collisionHeight:S,offset:[p[0]+M[0],p[1]+M[1]],my:n.my,at:n.at,within:x,elem:u})}),n.using&&(l=function(e){var t=v.left-N.left,i=t+m-d,s=v.top-N.top,a=s+g-c,h={target:{element:_,left:v.left,top:v.top,width:m,height:g},element:{element:u,left:N.left,top:N.top,width:d,height:c},horizontal:0>i?"left":t>0?"right":"center",vertical:0>a?"top":s>0?"bottom":"middle"}>m&&m>r(t+i)&&(h.horizontal="center"),c>g&&g>r(s+a)&&(h.vertical="middle"),h.important=o(r(t),r(i))>o(r(s),r(a))?"horizontal":"vertical",n.using.call(this,e,h)}),u.offset(e.extend(N,{using:l}))})},e.ui.position={fit:{left:function(e,t){var i,s=t.within,n=s.isWindow?s.scrollLeft:s.offset.left,a=s.width,r=e.left-t.collisionPosition.marginLeft,h=n-r,l=r+t.collisionWidth-a-n;t.collisionWidth>a?h>0&&0>=l?(i=e.left+h+t.collisionWidth-a-n,e.left+=h-i):e.left=l>0&&0>=h?n:h>l?n+a-t.collisionWidth:n:h>0?e.left+=h:l>0?e.left-=l:e.left=o(e.left-r,e.left)},top:function(e,t){var i,s=t.within,n=s.isWindow?s.scrollTop:s.offset.top,a=t.within.height,r=e.top-t.collisionPosition.marginTop,h=n-r,l=r+t.collisionHeight-a-n;t.collisionHeight>a?h>0&&0>=l?(i=e.top+h+t.collisionHeight-a-n,e.top+=h-i):e.top=l>0&&0>=h?n:h>l?n+a-t.collisionHeight:n:h>0?e.top+=h:l>0?e.top-=l:e.top=o(e.top-r,e.top)}},flip:{left:function(e,t){var i,s,n=t.within,a=n.offset.left+n.scrollLeft,o=n.width,h=n.isWindow?n.scrollLeft:n.offset.left,l=e.left-t.collisionPosition.marginLeft,u=l-h,d=l+t.collisionWidth-o-h,c="left"===t.my[0]?-t.elemWidth:"right"===t.my[0]?t.elemWidth:0,p="left"===t.at[0]?t.targetWidth:"right"===t.at[0]?-t.targetWidth:0,f=-2*t.offset[0];0>u?(i=e.left+c+p+f+t.collisionWidth-o-a,(0>i||r(u)>i)&&(e.left+=c+p+f))>0&&(s=e.left-t.collisionPosition.marginLeft+c+p+f-h,(s>0||d>r(s))&&(e.left+=c+p+f))},top:function(e,t){var i,s,n=t.within,a=n.offset.top+n.scrollTop,o=n.height,h=n.isWindow?n.scrollTop:n.offset.top,l=e.top-t.collisionPosition.marginTop,u=l-h,d=l+t.collisionHeight-o-h,c="top"===t.my[1],p=c?-t.elemHeight:"bottom"===t.my[1]?t.elemHeight:0,f="top"===t.at[1]?t.targetHeight:"bottom"===t.at[1]?-t.targetHeight:0,m=-2*t.offset[1];0>u?(s=e.top+p+f+m+t.collisionHeight-o-a,e.top+p+f+m>u&&(0>s||r(u)>s)&&(e.top+=p+f+m))>0&&(i=e.top-t.collisionPosition.marginTop+p+f+m-h,e.top+p+f+m>d&&(i>0||d>r(i))&&(e.top+=p+f+m))}},flipfit:{left:function(){e.ui.position.flip.left.apply(this,arguments),e.ui.position.fit.left.apply(this,arguments)},top:function(){e.ui.position.flip.top.apply(this,arguments),e.ui.position.fit.top.apply(this,arguments)}}},function(){var t,i,s,n,o,r=document.getElementsByTagName("body")[0],h=document.createElement("div");t=document.createElement(r?"div":"body"),s={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},r&&e.extend(s,{position:"absolute",left:"-1000px",top:"-1000px"});for(o in s)t.style[o]=s[o];t.appendChild(h),i=r||document.documentElement,i.insertBefore(t,i.firstChild),h.style.cssText="position: absolute; left: 10.7432222px;",n=e(h).offset().left,a=n>10&&11>n,t.innerHTML="",i.removeChild(t)}()}(),e.ui.position,e.widget("ui.menu",{version:"1.11.2",defaultElement:"<ul>",delay:300,options:{icons:{submenu:"ui-icon-carat-1-e"},items:"> *",menus:"ul",position:{my:"left-1 top",at:"right top"},role:"menu",blur:null,focus:null,select:null},_create:function(){this.activeMenu=this.element,this.mouseHandled=!1,this.element.uniqueId().addClass("ui-menu ui-widget ui-widget-content").toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length).attr({role:this.options.role,tabIndex:0}),this.options.disabled&&this.element.addClass("ui-state-disabled").attr("aria-disabled","true"),this._on({"mousedown .ui-menu-item":function(e){e.preventDefault()},"click .ui-menu-item":function(t){var i=e(t.target);!this.mouseHandled&&i.not(".ui-state-disabled").length&&(this.select(t),t.isPropagationStopped()||(this.mouseHandled=!0),i.has(".ui-menu").length?this.expand(t):!this.element.is(":focus")&&e(this.document[0].activeElement).closest(".ui-menu").length&&(this.element.trigger("focus",[!0]),this.active&&1===this.active.parents(".ui-menu").length&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":function(t){if(!this.previousFilter){var i=e(t.currentTarget);i.siblings(".ui-state-active").removeClass("ui-state-active"),this.focus(t,i)}},mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(e,t){var i=this.active||this.element.find(this.options.items).eq(0);t||this.focus(e,i)},blur:function(t){this._delay(function(){e.contains(this.element[0],this.document[0].activeElement)||this.collapseAll(t)})},keydown:"_keydown"}),this.refresh(),this._on(this.document,{click:function(e){this._closeOnDocumentClick(e)&&this.collapseAll(e),this.mouseHandled=!1}})},_destroy:function(){this.element.removeAttr("aria-activedescendant").find(".ui-menu").addBack().removeClass("ui-menu ui-widget ui-widget-content ui-menu-icons ui-front").removeAttr("role").removeAttr("tabIndex").removeAttr("aria-labelledby").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-disabled").removeUniqueId().show(),this.element.find(".ui-menu-item").removeClass("ui-menu-item").removeAttr("role").removeAttr("aria-disabled").removeUniqueId().removeClass("ui-state-hover").removeAttr("tabIndex").removeAttr("role").removeAttr("aria-haspopup").children().each(function(){var t=e(this);t.data("ui-menu-submenu-carat")&&t.remove()}),this.element.find(".ui-menu-divider").removeClass("ui-menu-divider ui-widget-content")},_keydown:function(t){var i,s,n,a,o=!0;switch(t.keyCode){case e.ui.keyCode.PAGE_UP:this.previousPage(t);break;case e.ui.keyCode.PAGE_DOWN:this.nextPage(t);break;case e.ui.keyCode.HOME:this._move("first","first",t);break;case e.ui.keyCode.END:this._move("last","last",t);break;case e.ui.keyCode.UP:this.previous(t);break;case e.ui.keyCode.DOWN:this.next(t);break;case e.ui.keyCode.LEFT:this.collapse(t);break;case e.ui.keyCode.RIGHT:this.active&&!this.active.is(".ui-state-disabled")&&this.expand(t);break;case e.ui.keyCode.ENTER:case e.ui.keyCode.SPACE:this._activate(t);break;case e.ui.keyCode.ESCAPE:this.collapse(t);break;default:o=!1,s=this.previousFilter||"",n=String.fromCharCode(t.keyCode),a=!1,clearTimeout(this.filterTimer),n===s?a=!0:n=s+n,i=this._filterMenuItems(n),i=a&&-1!==i.index(this.active.next())?this.active.nextAll(".ui-menu-item"):i,i.length||(n=String.fromCharCode(t.keyCode),i=this._filterMenuItems(n)),i.length?(this.focus(t,i),this.previousFilter=n,this.filterTimer=this._delay(function(){delete this.previousFilter},1e3)):delete this.previousFilter}o&&t.preventDefault()},_activate:function(e){this.active.is(".ui-state-disabled")||(this.active.is("[aria-haspopup='true']")?this.expand(e):this.select(e))},refresh:function(){var t,i,s=this,n=this.options.icons.submenu,a=this.element.find(this.options.menus);this.element.toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length),a.filter(":not(.ui-menu)").addClass("ui-menu ui-widget ui-widget-content ui-front").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"}).each(function(){var t=e(this),i=t.parent(),s=e("<span>").addClass("ui-menu-icon ui-icon "+n).data("ui-menu-submenu-carat",!0);i.attr("aria-haspopup","true").prepend(s),t.attr("aria-labelledby",i.attr("id"))}),t=a.add(this.element),i=t.find(this.options.items),i.not(".ui-menu-item").each(function(){var t=e(this);s._isDivider(t)&&t.addClass("ui-widget-content ui-menu-divider")}),i.not(".ui-menu-item, .ui-menu-divider").addClass("ui-menu-item").uniqueId().attr({tabIndex:-1,role:this._itemRole()}),i.filter(".ui-state-disabled").attr("aria-disabled","true"),this.active&&!e.contains(this.element[0],this.active[0])&&this.blur()},_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},_setOption:function(e,t){"icons"===e&&this.element.find(".ui-menu-icon").removeClass(this.options.icons.submenu).addClass(t.submenu),"disabled"===e&&this.element.toggleClass("ui-state-disabled",!!t).attr("aria-disabled",t),this._super(e,t)},focus:function(e,t){var i,s;this.blur(e,e&&"focus"===e.type),this._scrollIntoView(t),this.active=t.first(),s=this.active.addClass("ui-state-focus").removeClass("ui-state-active"),this.options.role&&this.element.attr("aria-activedescendant",s.attr("id")),this.active.parent().closest(".ui-menu-item").addClass("ui-state-active"),e&&"keydown"===e.type?this._close():this.timer=this._delay(function(){this._close()},this.delay),i=t.children(".ui-menu"),i.length&&e&&/^mouse/.test(e.type)&&this._startOpening(i),this.activeMenu=t.parent(),this._trigger("focus",e,{item:t})},_scrollIntoView:function(t){var i,s,n,a,o,r;this._hasScroll()&&(i=parseFloat(e.css(this.activeMenu[0],"borderTopWidth"))||0,s=parseFloat(e.css(this.activeMenu[0],"paddingTop"))||0,n=t.offset().top-this.activeMenu.offset().top-i-s,a=this.activeMenu.scrollTop(),o=this.activeMenu.height(),r=t.outerHeight(),0>n?this.activeMenu.scrollTop(a+n):n+r>o&&this.activeMenu.scrollTop(a+n-o+r))},blur:function(e,t){t||clearTimeout(this.timer),this.active&&(this.active.removeClass("ui-state-focus"),this.active=null,this._trigger("blur",e,{item:this.active}))},_startOpening:function(e){clearTimeout(this.timer),"true"===e.attr("aria-hidden")&&(this.timer=this._delay(function(){this._close(),this._open(e)},this.delay))},_open:function(t){var i=e.extend({of:this.active},this.options.position);clearTimeout(this.timer),this.element.find(".ui-menu").not(t.parents(".ui-menu")).hide().attr("aria-hidden","true"),t.show().removeAttr("aria-hidden").attr("aria-expanded","true").position(i)},collapseAll:function(t,i){clearTimeout(this.timer),this.timer=this._delay(function(){var s=i?this.element:e(t&&t.target).closest(this.element.find(".ui-menu"));s.length||(s=this.element),this._close(s),this.blur(t),this.activeMenu=s},this.delay)},_close:function(e){e||(e=this.active?this.active.parent():this.element),e.find(".ui-menu").hide().attr("aria-hidden","true").attr("aria-expanded","false").end().find(".ui-state-active").not(".ui-state-focus").removeClass("ui-state-active")},_closeOnDocumentClick:function(t){return!e(t.target).closest(".ui-menu").length},_isDivider:function(e){return!/[^\-\u2014\u2013\s]/.test(e.text())},collapse:function(e){var t=this.active&&this.active.parent().closest(".ui-menu-item",this.element);t&&t.length&&(this._close(),this.focus(e,t))},expand:function(e){var t=this.active&&this.active.children(".ui-menu ").find(this.options.items).first();t&&t.length&&(this._open(t.parent()),this._delay(function(){this.focus(e,t)}))},next:function(e){this._move("next","first",e)},previous:function(e){this._move("prev","last",e)},isFirstItem:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},isLastItem:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},_move:function(e,t,i){var s;this.active&&(s="first"===e||"last"===e?this.active["first"===e?"prevAll":"nextAll"](".ui-menu-item").eq(-1):this.active[e+"All"](".ui-menu-item").eq(0)),s&&s.length&&this.active||(s=this.activeMenu.find(this.options.items)[t]()),this.focus(i,s)},nextPage:function(t){var i,s,n;return this.active?(this.isLastItem()||(this._hasScroll()?(s=this.active.offset().top,n=this.element.height(),this.active.nextAll(".ui-menu-item").each(function(){return i=e(this),0>i.offset().top-s-n}),this.focus(t,i)):this.focus(t,this.activeMenu.find(this.options.items)[this.active?"last":"first"]())),void 0):(this.next(t),void 0)},previousPage:function(t){var i,s,n;return this.active?(this.isFirstItem()||(this._hasScroll()?(s=this.active.offset().top,n=this.element.height(),this.active.prevAll(".ui-menu-item").each(function(){return i=e(this),i.offset().top-s+n>0}),this.focus(t,i)):this.focus(t,this.activeMenu.find(this.options.items).first())),void 0):(this.next(t),void 0)},_hasScroll:function(){return this.element.outerHeight()<this.element.prop("scrollHeight")},select:function(t){this.active=this.active||e(t.target).closest(".ui-menu-item");var i={item:this.active};this.active.has(".ui-menu").length||this.collapseAll(t,!0),this._trigger("select",t,i)},_filterMenuItems:function(t){var i=t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&"),s=RegExp("^"+i,"i");return this.activeMenu.find(this.options.items).filter(".ui-menu-item").filter(function(){return s.test(e.trim(e(this).text()))})}}),e.widget("ui.autocomplete",{version:"1.11.2",defaultElement:"<input>",options:{appendTo:null,autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null,change:null,close:null,focus:null,open:null,response:null,search:null,select:null},requestIndex:0,pending:0,_create:function(){var t,i,s,n=this.element[0].nodeName.toLowerCase(),a="textarea"===n,o="input"===n;this.isMultiLine=a?!0:o?!1:this.element.prop("isContentEditable"),this.valueMethod=this.element[a||o?"val":"text"],this.isNewMenu=!0,this.element.addClass("ui-autocomplete-input").attr("autocomplete","off"),this._on(this.element,{keydown:function(n){if(this.element.prop("readOnly"))return t=!0,s=!0,i=!0,void 0;t=!1,s=!1,i=!1;var a=e.ui.keyCode;switch(n.keyCode){case a.PAGE_UP:t=!0,this._move("previousPage",n);break;case a.PAGE_DOWN:t=!0,this._move("nextPage",n);break;case a.UP:t=!0,this._keyEvent("previous",n);break;case a.DOWN:t=!0,this._keyEvent("next",n);break;case a.ENTER:this.menu.active&&(t=!0,n.preventDefault(),this.menu.select(n));break;case a.TAB:this.menu.active&&this.menu.select(n);break;case a.ESCAPE:this.menu.element.is(":visible")&&(this.isMultiLine||this._value(this.term),this.close(n),n.preventDefault());break;default:i=!0,this._searchTimeout(n)}},keypress:function(s){if(t)return t=!1,(!this.isMultiLine||this.menu.element.is(":visible"))&&s.preventDefault(),void 0;if(!i){var n=e.ui.keyCode;switch(s.keyCode){case n.PAGE_UP:this._move("previousPage",s);break;case n.PAGE_DOWN:this._move("nextPage",s);break;case n.UP:this._keyEvent("previous",s);break;case n.DOWN:this._keyEvent("next",s)}}},input:function(e){return s?(s=!1,e.preventDefault(),void 0):(this._searchTimeout(e),void 0)},focus:function(){this.selectedItem=null,this.previous=this._value()},blur:function(e){return this.cancelBlur?(delete this.cancelBlur,void 0):(clearTimeout(this.searching),this.close(e),this._change(e),void 0)}}),this._initSource(),this.menu=e("<ul>").addClass("ui-autocomplete ui-front").appendTo(this._appendTo()).menu({role:null}).hide().menu("instance"),this._on(this.menu.element,{mousedown:function(t){t.preventDefault(),this.cancelBlur=!0,this._delay(function(){delete this.cancelBlur});var i=this.menu.element[0];e(t.target).closest(".ui-menu-item").length||this._delay(function(){var t=this;this.document.one("mousedown",function(s){s.target===t.element[0]||s.target===i||e.contains(i,s.target)||t.close()})})},menufocus:function(t,i){var s,n;return this.isNewMenu&&(this.isNewMenu=!1,t.originalEvent&&/^mouse/.test(t.originalEvent.type))?(this.menu.blur(),this.document.one("mousemove",function(){e(t.target).trigger(t.originalEvent)}),void 0):(n=i.item.data("ui-autocomplete-item"),!1!==this._trigger("focus",t,{item:n})&&t.originalEvent&&/^key/.test(t.originalEvent.type)&&this._value(n.value),s=i.item.attr("aria-label")||n.value,s&&e.trim(s).length&&(this.liveRegion.children().hide(),e("").text(s).appendTo(this.liveRegion)),void 0)},menuselect:function(e,t){var i=t.item.data("ui-autocomplete-item"),s=this.previous;this.element[0]!==this.document[0].activeElement&&(this.element.focus(),this.previous=s,this._delay(function(){this.previous=s,this.selectedItem=i})),!1!==this._trigger("select",e,{item:i})&&this._value(i.value),this.term=this._value(),this.close(e),this.selectedItem=i}}),this.liveRegion=e("<span>",{role:"status","aria-live":"assertive","aria-relevant":"additions"}).addClass("ui-helper-hidden-accessible").appendTo(this.document[0].body),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_destroy:function(){clearTimeout(this.searching),this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete"),this.menu.element.remove(),this.liveRegion.remove()},_setOption:function(e,t){this._super(e,t),"source"===e&&this._initSource(),"appendTo"===e&&this.menu.element.appendTo(this._appendTo()),"disabled"===e&&t&&this.xhr&&this.xhr.abort()},_appendTo:function(){var t=this.options.appendTo;return t&&(t=t.jquery||t.nodeType?e(t):this.document.find(t).eq(0)),t&&t[0]||(t=this.element.closest(".ui-front")),t.length||(t=this.document[0].body),t},_initSource:function(){var t,i,s=this;e.isArray(this.options.source)?(t=this.options.source,this.source=function(i,s){s(e.ui.autocomplete.filter(t,i.term))}):"string"==typeof this.options.source?(i=this.options.source,this.source=function(t,n){s.xhr&&s.xhr.abort(),s.xhr=e.ajax({url:i,data:t,dataType:"json",success:function(e){n(e)},error:function(){n([])}})}):this.source=this.options.source},_searchTimeout:function(e){clearTimeout(this.searching),this.searching=this._delay(function(){var t=this.term===this._value(),i=this.menu.element.is(":visible"),s=e.altKey||e.ctrlKey||e.metaKey||e.shiftKey;(!t||t&&!i&&!s)&&(this.selectedItem=null,this.search(null,e))},this.options.delay)},search:function(e,t){return e=null!=e?e:this._value(),this.term=this._value(),e.length<this.options.minLength?this.close(t):this._trigger("search",t)!==!1?this._search(e):void 0},_search:function(e){this.pending++,this.element.addClass("ui-autocomplete-loading"),this.cancelSearch=!1,this.source({term:e},this._response())},_response:function(){var t=++this.requestIndex;return e.proxy(function(e){t===this.requestIndex&&this.__response(e),this.pending--,this.pending||this.element.removeClass("ui-autocomplete-loading")},this)},__response:function(e){e&&(e=this._normalize(e)),this._trigger("response",null,{content:e}),!this.options.disabled&&e&&e.length&&!this.cancelSearch?(this._suggest(e),this._trigger("open")):this._close()},close:function(e){this.cancelSearch=!0,this._close(e)},_close:function(e){this.menu.element.is(":visible")&&(this.menu.element.hide(),this.menu.blur(),this.isNewMenu=!0,this._trigger("close",e))},_change:function(e){this.previous!==this._value()&&this._trigger("change",e,{item:this.selectedItem})},_normalize:function(t){return t.length&&t[0].label&&t[0].value?t:e.map(t,function(t){return"string"==typeof t?{label:t,value:t}:e.extend({},t,{label:t.label||t.value,value:t.value||t.label})})},_suggest:function(t){var i=this.menu.element.empty();this._renderMenu(i,t),this.isNewMenu=!0,this.menu.refresh(),i.show(),this._resizeMenu(),i.position(e.extend({of:this.element},this.options.position)),this.options.autoFocus&&this.menu.next() },_resizeMenu:function(){var e=this.menu.element;e.outerWidth(Math.max(e.width("").outerWidth()+1,this.element.outerWidth()))},_renderMenu:function(t,i){var s=this;e.each(i,function(e,i){s._renderItemData(t,i)})},_renderItemData:function(e,t){return this._renderItem(e,t).data("ui-autocomplete-item",t)},_renderItem:function(t,i){return e("<li>").text(i.label).appendTo(t)},_move:function(e,t){return this.menu.element.is(":visible")?this.menu.isFirstItem()&&/^previous/.test(e)||this.menu.isLastItem()&&/^next/.test(e)?(this.isMultiLine||this._value(this.term),this.menu.blur(),void 0):(this.menu[e](t),void 0):(this.search(null,t),void 0)},widget:function(){return this.menu.element},_value:function(){return this.valueMethod.apply(this.element,arguments)},_keyEvent:function(e,t){(!this.isMultiLine||this.menu.element.is(":visible"))&&(this._move(e,t),t.preventDefault())}}),e.extend(e.ui.autocomplete,{escapeRegex:function(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")},filter:function(t,i){var s=RegExp(e.ui.autocomplete.escapeRegex(i),"i");return e.grep(t,function(e){return s.test(e.label||e.value||e)})}}),e.widget("ui.autocomplete",e.ui.autocomplete,{options:{messages:{noResults:"No search results.",results:function(e){return e+(e>1?" results are":" result is")+" available, use up and down arrow keys to navigate."}}},__response:function(t){var i;this._superApply(arguments),this.options.disabled||this.cancelSearch||(i=t&&t.length?this.options.messages.results(t.length):this.options.messages.noResults,this.liveRegion.children().hide(),e("<div>").text(i).appendTo(this.liveRegion))}}),e.ui.autocomplete});
  24. dishadcruze

    summing two variables which has been added dynamically

    Oh! can you please guide me how to solve it? I feel problem is with function ttotal1() { var ttt = 0; var ty1 = tr.find('.total').val(); var ty2 = tr.find('.ttotal').val(); ttt = ty1+ty2; ttt = Number((ttt).toFixed(2)); $('.ttotal1').html(ttt); } alert(ttt) is not giving any values and calling this function is what i am not doing right, tr.find('.ttotal').val(amt); ttotal1(); .val(amt) is confusing me
  25. dishadcruze

    summing two variables which has been added dynamically

    Yes . This is the one https://jsfiddle.net/cwmoo4hm/6/ , Where i have updated my code. I checked it and it is there
×

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.