jquery

HTML form for multiple objects when converting to JSON

大兔子大兔子 提交于 2021-02-20 04:42:06
问题 Edited: $.fn.serializeObject = function() { var o = {}; var a = this.serializeArray(); $.each(a, function() { var value = this.value || ''; if (/^\d+$/.test(value)) value = +value; if (o[this.name] !== undefined) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(value); } else { o[this.name] = value; } }); return o; };` Edited to hopefully make clearer. Having difficulty wrapping my head around this - sleep deprivation = madness. I have a form that simply

How to pass the values of localstorage from view to controller to use as php variable in another view

老子叫甜甜 提交于 2021-02-20 04:12:56
问题 In view on click of button am using location.href to pass on to controller. How can i pass the localstorage value in order to use it as a php variable In view: echo Html::button('Proceed', [ 'onclick' => " var dataVal = localStorage.getItem('Customers'); if(dataVal.length > 0) { location.href = '" . Yii::$app->urlManager->createUrl(['customers/orders']) . "'; }else{ alert('Please add some items to order!') return false; }",]); 回答1: While this is generally not recommended practice, it is

How to pass the values of localstorage from view to controller to use as php variable in another view

邮差的信 提交于 2021-02-20 04:12:12
问题 In view on click of button am using location.href to pass on to controller. How can i pass the localstorage value in order to use it as a php variable In view: echo Html::button('Proceed', [ 'onclick' => " var dataVal = localStorage.getItem('Customers'); if(dataVal.length > 0) { location.href = '" . Yii::$app->urlManager->createUrl(['customers/orders']) . "'; }else{ alert('Please add some items to order!') return false; }",]); 回答1: While this is generally not recommended practice, it is

Custom jQuery Tooltip: How to position it?

这一生的挚爱 提交于 2021-02-20 04:11:57
问题 I've got a custom tooltip being pulled by Ajax, when you rollover a link, great...e.g. <script type="text/javascript"> $(document).ready(function(){ $('.tippytrip').hover(function(){ var tooltipId = this.hash; $('#tooltip-container').empty().load('tooltips.html ' + tooltipId).show(); }, function(){ $('#tooltip-container').hide(); });}); </script> So this shows the div... "tooltip-container" But I think i'll need some further jQuery assistance in actually positioning the tooltip next to each

Custom jQuery Tooltip: How to position it?

烈酒焚心 提交于 2021-02-20 04:09:05
问题 I've got a custom tooltip being pulled by Ajax, when you rollover a link, great...e.g. <script type="text/javascript"> $(document).ready(function(){ $('.tippytrip').hover(function(){ var tooltipId = this.hash; $('#tooltip-container').empty().load('tooltips.html ' + tooltipId).show(); }, function(){ $('#tooltip-container').hide(); });}); </script> So this shows the div... "tooltip-container" But I think i'll need some further jQuery assistance in actually positioning the tooltip next to each

adjust jqgrid height

家住魔仙堡 提交于 2021-02-20 03:55:48
问题 I need to adjust my jqgrid height dynamically to fit in the browser window as screen resolution changes.I need to calculate the header and footer ,and form(optional)..Then grid should be fitted in the remaining space. 回答1: You could set the height of the .ui-jqgrid-bdiv element via css calculating the height based on the window.innerHeight property. Like here I will set the grid height to be 70% of the available window space: $("#gview_mygrid > .ui-jqgrid-bdiv").css('height', window

fade changing image every n seconds

末鹿安然 提交于 2021-02-20 03:54:08
问题 I want to change an image every 3 seconds, but when changing I want to make a fade effect, to do so I was doing: <script type="text/javascript"> var images = []; images[0] = "http://i2.ytimg.com/vi/Q1yo3mco40U/default.jpg"; images[1] = "http://i2.ytimg.com/vi/ivmoCcYLrEk/default.jpg"; images[2] = "http://i3.ytimg.com/vi/f7d8luQ6p2Q/default.jpg"; images[3] = "http://i1.ytimg.com/vi/XzFmOKNf8sc/default.jpg"; images[4] = "http://i2.ytimg.com/vi/-2m1e4g2MFM/default.jpg"; images[5] = "http://i1

Fetch data from database and update webpage continuously

扶醉桌前 提交于 2021-02-20 02:58:09
问题 All I want to do is fetch a string from a database and display it on my website but have it refresh continuously. This is the code a friend wrote for me quickly but I really don't know anything about it and he's not here to help me and I need to have it done by tonight. The query is just $sql = "SELECT status FROM light"; $result = $conn->query($sql); I know it should be easy but I really can't figure it out. Thanks allot! setInterval(function() { // Variables let URL = "/localhost/form.php";

searching a jquery datatables

霸气de小男生 提交于 2021-02-20 02:57:26
问题 I am using jquery datatables 1.10 and trying to search and filter a table. I would like to use a search text box that searches two columns and a check box to filter the results of a third column. Here is my datatable: var url = '@Url.Action("SupportClass1Search", "SupportClass1")'; $('#SupportClass1DataTable').DataTable({ "serverSide": true, "processing": true, "ajax": url, "ordering": true, "dom": '<"top"prl<"clear">>t<"bottom">pi<"clear">', "pageLength": 10, "autoWidth": false, "columns": [

Spinner bound to ajax call will not display unless I put an alert in the javascript

偶尔善良 提交于 2021-02-20 02:17:45
问题 I wrote a simple method that adds a spinner to the main body of an html page and binds the event to an ajaxstart method then removes it on the ajaxstop. StartAjaxCallSpinner = function (spinnerObj) { var $bod = $("Body"); if ($('#bgSpinnerDiv')[0] == undefined && $('#spinnerHolder')[0] == undefined) { $bod.append("<div id='spinnerHolder' style='display:none;'></div><div id='bgSpinnerDiv'></div>"); } $('#spinnerHolder') .hide() .ajaxStart(function () { $('#bgSpinnerDiv').css({ 'background