w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » JAVASCRIPT » Page 53
Accessing Class properties returns "Undefined"
The scale method is defined on the path object. In the destruct function, you have to call scale on the path object. destruct: function(ball) { ball.path.scale(0,0); }

Categories : Javascript

Phalcon and Angular JS routing - use Angular templates and Phalcon controllers
Constructing your router passing false as parameter would be enough to not add the default routes. Only the ones you explicitly add will be matched. However your problems are more likely coming from your client-side router. Please read carefully about the $location service to understand how make angular be able to tell if the current route should be retrieved from your server or not. I would li

Categories : Javascript

How to pass input to the following code?
I'm not sure what exactly you want. If you want to get the input from stdin and send _input to processData function, you may use something like this. User can end giving input by just pressing the enter without typing. function processData(input) { //Enter your code here console.log(input); } process.stdin.resume(); process.stdin.setEncoding("ascii"); _input = ""; process.stdin.on("data

Categories : Javascript

How can Window.open link change main page url
In your Main page, of course have that link that will open then child (other) file: <div class="main"> <a href="#" onclick="window.open('another_file.php', 'window', 'height=200,width=200');">Open new window</a> </div> Then on that other file: <a href="#" onclick="redirect_parent()">Redirect Parent to google.com</a> <script type="text/javascript">

Categories : Javascript

Hiding the beginning of a text block with overflow:hidden
Here's one way: 1) Place the text in a wrapper element with position:absolute and bottom:0 2) Since the text will always be larger than the width of outer div...as the question says: I have a div element which is deliberately too small for the text inside it. ...we can set an ellipsis before the text using generated content on the outer element DEMO div { width: 120px; height:

Categories : Javascript

Execute PHP code and query after javascript callback
If you want execute a server side code (for example PHP), then you will have to either submit the page or make an AJAX call. From the minimal information you've provided it is not clear whether you want to submit the page after the event. If you want to retain the page but only update the page with the result of whatever your PHP does, then you can make an AJAX call and use the response to update

Categories : Javascript

accessing php from remote server using ajax jquery
You have two options 1.Using localhost try this url theUrl=http://10.0.2.2/yourfilepath but this will work only in emulator not in browser.If you want test browser disable the web security first and then try it. 2.Using liveserver Access the files like a website url access eg:www.apptest.in/test/auth.php

Categories : Javascript

Sorted parameters in query string from two JavaScript object in Node.js
As object properties can not be sorted (their order is unspecified), you would need to put them in an array. You can make an object that handles a key-value pair: function KeyValue(key, value) { this.key = key; this.value = value; } KeyValue.prototype = { toString: function() { return encodeURIComponent(this.key) + '=' + encodeURIComponent(this.value); } }; By creating an array of

Categories : Javascript

Javascript +/- with quantity limit
You just have to follow the way you have implemented to control the minimum. The opposite is for the maximum.. <img alt="" src="catalog/view/theme/default/image/minus.png" border="0" style="cursor:pointer;display:inline-block;" onclick="btnminus(<?php echo $minimum; ?>);"> <input type="text" name="quantity" id="quantity" size="2" value="<?php echo $minimum; ?>" /> <img

Categories : Javascript

Plotting Points on a Map with d3.js
Did you get any output with your code, as you've got a couple of syntax errors, such as: proj vs projection (in the calculation of the circle x and y positions) svg vs india (the variable svg doesn't exist when you try to create the circles) After correcting those syntax errors, your code still doesn't work as expected, with nothing visible in the browser, probably because of: The projection

Categories : Javascript

Calculate date difference in javascript
Your code is calculating the difference between Feb 1, 1900 and Dec 16, 2014 (41956 days). The value month should be between 0...11 (where 0 is January). Correct the month numbers to get the expected result: var _MS_PER_Day = 1000 * 60 * 60 * 24; var utc1 = Date.UTC(1900, 0, 1); // Jan 01, 1900 var utc2 = Date.UTC(2014, 10, 16); // Nov 16, 2014 var x = Math.ceil((utc2 - utc1) / _MS_PER_Day); aler

Categories : Javascript

How to keep Bootstrap tooltip after changing element?
According to the Bootstrap website, "a tooltip and popover data-apis are opt in, meaning you must initialize them yourself." Therefore, to achieve your goal, one must re-initialize the bootstrap tooltip, as mentioned by Miraage. Here is a nice tutorial that may help: http://www.tutorialrepublic.com/twitter-bootstrap-tutorial/bootstrap-tooltips.php Hope this helps!

Categories : Javascript

Trigger Google Maps event listener on link clicks
I'm not sure what you're looking for but I think this can help you: JavaScript function in href vs. onclick

Categories : Javascript

Javascript: How do I make a calendar selection?
JavaScript has no built-in calendar user interface. I see from the script tags and use of prompt in your question that you're using JavaScript in a browser: Very up-to-date browsers may provide one on an <input type="date"> field (one of the new types defined by HTML5), but support varies. Otherwise, you might look at any of the several hundred "datepicker" libraries out there. One example i

Categories : Javascript

Add jQuery Event to Single Text Link
You need to do 2 steps: 1) Add new <li> to <ul id="menu"> <li><a class="newtab" href="#newtab" title="New Tab">New Tab</a><span>Get in touch</span></li> 2) Add new div into <div id="content"> like <div id="newtab" class="section">Content goes here</div> Other way add function to your javascript section function showTab(t

Categories : Javascript

Javascript from onmouseover to onclick
try this: change from h.onmouseover=new Function(this.n+'.st('+i+',true)'); h.onmouseout=new Function(this.n+'.st('+i+')'); change to h.onclick=new Function(this.n+'.st('+i+',true)');

Categories : Javascript

Create div overlay for image based on xml attributes
Yes, it is possible this way, with simple html markup: <div class="image_box" data-cords="20,50,210,50,50,250,240,250">I am the text inside the div, I can be in several lines. It is important for text stay vertical and it is important the text to follow boundary box.</div> Than do some script magic: $.fn.skewText = function () { return this.each(function (i) { var thisT

Categories : Javascript

How to retrieve data from html page using html class?
document.getElementsByClassName("MyName") will return you collection of element that has class "MyName", you can retrieve required by it's index var elements= document.getElementsByClassName("MyName"); if(elements.length > 0){ var value = elements[0].innerHTML; }

Categories : Javascript

How to get height of a div with overflow hidden?
Use scrollHeight instead (a DOM element property): $(selector)[0].scrollHeight so in your example: var height= $("#container")[0].scrollHeight; or (as Vohuman points out): var height= $("#container").prop("scrollHeight");

Categories : Javascript

How to check if validation fails while saving data in sharepoint spservice
Your answer is in this SPServices forum post: http://spservices.codeplex.com/discussions/393036 I believe Marc has an issue open to add the methods I posted in that thread to SPServices in some future release.

Categories : Javascript

How can I rewrite this javascript code, so that it will refer to every optionbox?
ID must be unique. I suggest to use a function on every select on change event and pass this as parameter like: function changeDate(obj) { var chosenoption = obj.options[obj.selectedIndex]; if (chosenoption.value == "other") { var winProVal = window.prompt("Enter the date", ""); if (winProVal != null) { obj.options[obj.value].value = obj.options[obj.value].text = winProVal;

Categories : Javascript

Optimizing the hiding and showing of html elements
Try changing your editor's font to a smaller size. I'm going to assume that #loginbox is a child of #desno and give you this: #loginbox {display:none} #desno:hover #loginbox {display:block} <div id="desno"> I am desno <div id="loginbox">I am loginbox</div> </div> Good luck getting anything smaller than that.

Categories : Javascript

Printing arrays of a JSON object
Your edit completely changes the question. Yes, that JSON is valid. You parse it via JSON.parse: var obj = JSON.parse(immovable_property); ...and then access the named properties on the result, e.g.: console.log(obj.immovable_subdivision.length); // 4 You can get a list of all of the property names via Object.keys, which returns an array. Example: // Your string var immovable_property =

Categories : Javascript

Google Maps API 3, c# MVC5
The problem was in separator. In DB there was comma, in VS there was point. But in razor in js there was comma again. I solved it like that. var latit = @Model[0].latitude.ToString().Replace(',','.'); var longit = @Model[0].longitude.ToString().Replace(',','.'); var marker = new google.maps.Marker({ position: new google.maps.LatLng(latit, longit), map: map,

Categories : Javascript

How to get value form name[] of textbox [script]
PS: use the required attribute instead. Then on form submissions search for all required elements and loop over the fields function fnSubmit() { var requiredNodes = document.querySelectorAll("form[name=form1] [required]"); for(var i = 0; i < requiredNodes.length; i++){ if (!requiredNodes[i].value) { alert("please enter value"); requiredNodes[i].focus();

Categories : Javascript

How to get attribute inside square brackets with JavaScript
Use the below regex and get the value of background attribute from group index 2. [(w+)sS+?="([^]"]*)"](.*?)[/1] DEMO

Categories : Javascript

Add a callback function when a list (with images) is loaded
function loadImages(images, callback) { var length, count, check, i, img; length = images.length; count = length; check = function () { if (--count === 0) { callback(); } }; for (i = 0; i < length; i++) { img = new Image(); img.onload = check; img.onerror = check; img.src = images[i] } } var images = [

Categories : Javascript

Sails.js / Waterline: findOne() vs find()
I didn't think this one through but for the benefit of everyone who's googling, here's what's up: Once you dig into the err, you'll find: { "error": "E_UNKNOWN", "status": 500, "summary": "Encountered an unexpected error", "raw": {} } In other words, Waterline's findOne always requires some sort of a query to find one item; it won't automatically find first one on any list and return i

Categories : Javascript

Eliminate white space top between wordpress articles
Because this isn't how div-based html/css works, you're going to have to either use CSS3 columns, or JavaScript. You haven't shared any markup, but using CSS3 Columns will likely require you to restructure the way posts are currently being output. Also note that this will order posts top-to-bottom per row, rather than left-to-right. If you need posts ordered in rows from left to right, you'll wa

Categories : Javascript

jquery add data attribute while creating dynamic dom elements
Updated the code and fiddle. var div = $('#ajey'); var text = "<div class='parent'>parent div"; text +="<div class='child'>how do I add .data value for this div during on the fly dom creation?</div>"; text += "</div>"; div.html(text); div.find('.child').data('child', 'true'); //data-child attribute is added but will not show in DOM when user i

Categories : Javascript

Enyo custom event is not handled and undefined in simple example
When you use the event system in this way, you are typically expecting a component higher up the chain to handle the onModelChanged event, not the component that defines the event. Further, enyo.Model is a special case and uses a different observer mechanism, I believe. That's probably why you are getting "undefined" for the function call, because there is no magic mapping between onModelChanged

Categories : Javascript

Stationing ajax loading image on the center of a page
You need to use CSS for that. #load_spin { display: block; position: absolute; top: 50%, left: 50%; margin-top: -30px; margin-left: -30px; } Provided the parent element of #load_spin is relatively positioned, the above CSS will make sure that the element with the id load_spin is horizontally and vertically centered within this container.

Categories : Javascript

Compress JSON responce in PHP
The best way is just to enable HTTP traffic compression in web server. All modern browsers and servers support it. Read more about HTTP_compression. And you will have additional bonus: all your traffic will be compressed, not AJAX traffic only.

Categories : Javascript

Verify and convert input string to new Date object
Something like this would do the trick. Basically, take advantage of Date.parse, if the result is NaN then it didn't parse successfully. function getDate(dateString){ var date = Date.parse(dateString); if(isNaN(date)) return null; return new Date(date); } alert(getDate('11/19/2014 6:20 PM')); alert(getDate('11/35/2014 6:20 PM')); alert(getDate('11/19/2014 6:20 PM hello')); alert(g

Categories : Javascript

Cannot read property 'className' of null
I'd say this comes from the fact the body is not loaded when you try to get the #color element. Just wrap the thing inside this window.onload = function () { // your code }; Or you can load your code at the end of the body <body> <!-- you content --> <script src="your-script.js"></script> </body> And finally you can listen for the DOMContentLoaded e

Categories : Javascript

jQuery X-editable pass selected text from select
OK so after a bit of tracking down it turns out that the input elements provided by X-editable do not have ID's or Names available, however, they are wrapped in a div with a class of editable-input. Changing the above line of code from: url: 'handlers/putHDMTicketDetails.ashx?ac=1', to url: 'handlers/putHDMTicketDetails.ashx?ac=1&new=' + $('.editable-input').find(':selected').text(), so

Categories : Javascript

Javascript animation rectangle
Your update function changes recty but then this is overwritten in the first line of draw. recty = canvasHeight / 100 * 20; I've just moved this line from draw to init. window.onload = window.onresize = function() { var C = 1; // canvas width to viewport width ratio var W_TO_H = 2 / 1; // canvas width to canvas height ratio var el = document.getElementById("myCanvas"); var viewport

Categories : Javascript

Iframe auto Re-size when content of iframe change
try adding this to your iframe source: $(document).ready(function(){ $('#engineType').change(function(){ $('#iframe1', window.parent.document).height($('#VehicleDetails').height() + 227); }); }); Make sure that you follow the Same-Origin Policy

Categories : Javascript

Javascript - window.getComputedStyle returns "auto" as element top and left properties
There is nothing to compute for top and left when the element does have a computed position set to static(that's the default). top and left are irrelevant in this case.

Categories : Javascript




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.