 |
 |
Hello everybody,
I have a Calendar in my page and I want to check if users select Saturday or Sundays, with getDay() function I can check day number, but I find out depend on operating system setting I get different number for Saturday or Sunday. So how is a proper way I can check this and be sure it is secure for every operating system settings.
Regards
Mazy
"This chancy chancy chancy world."
|
|
|
|
 |
That's odd behaviour - can you post the code please, including where you Parse the date out (if applicable, including date format)? In any case it probably isn't an OS thing, but a timezone/localisation problem (which happen to be different on the two OSs you are trying).
In the mean time you can try getUTCDay() , but I doubt it'll fix your problem.
|
|
|
|
 |
Thanks, Yes it can be for timezone/localisation problem too. Here is my code:
function ff_bfQuickMode7256046_validation(element, message)
{
if(element.value == '' )
return 'Please select a date for your apppointement.\n';
var myday = new Date(element.value) ;
myday.setDate(myday.getDate());
var weekday = myday.getDay();
alert(weekday);
if (weekday == 6 || weekday == 0 ) {
if (message=='') message = element.name+" faild in my test.\n"
message = 'We are close on Saturdays and Sundays.\n';
ff_validationFocus(element.name);
return message;
} // if
return '';
} // ff_bfQuickMode7256046_validation
The probelm is I get two different numbers for WEEKDAY on two different computer. So are you telling me that getDay() should return the same value globaly for all OS or setting..?
Mazy
"This chancy chancy chancy world."
|
|
|
|
 |
AFAICT it should - people seem to have problems parsing the date in the first place. I'd put a breakpoint on/after this line:
var myday = new Date(element.value) ;
myday will probably be different across the OSs (and possibly browsers). You might be better off splitting element.value yourself and using the constructor function Date (year, month, day)
|
|
|
|
 |
Thanks I will try that and see what happen
Mazy
"This chancy chancy chancy world."
|
|
|
|
 |
My date is like this: 2016-02-07 ( YYYY-MM-DD )
Mazy
"This chancy chancy chancy world."
|
|
|
|
 |
i want to compare dates .
startjourney=moment(moment($('#onDate').val()).format("DD/MM/YYYY")+' '+ $('#starttime').val(),"DD/MM/YYYY h:mm A");//concate date and time am getting 27/01/2016 12:00 AM
newDate=moment(startjourney).add(mapDuration[0],'days').add(mapDuration[2],'hours').add(mapDuration[4],'minutes').format("DD/MM/YYYY hh:mm A");//29/01/2016 10:17 AM
// returnJourneyDate=newDate.split(" ")[0];
//
// endTime=moment(newDate.split(" ")[1]+ ' '+newDate.split(" ")[2],"h:mm A ");
// selectedTime=moment($('#starttime').val(),"h:mm A");
alert(moment($('#returntime').val(),"HH:MM").toDate());
selectedjourney=moment($('#returndate').val()+' '+ moment($('#returntime').val(),"HH:MM")).toDate();//concate date and time as strings
selectedDate=moment(selectedjourney,"DD/MM/YYYY h:mm A").toDate();
var date=new Date(selectedjourney,"DD/MM/YYYY hh:mm tt");
var d=moment( $('#returntime').val(),"HH:MM").toDate();
var h=new Date(selectedDate);
if(selectedjourney.isBefore(newDate))// test selected one is before newDate
bootbox.alert( "Return journey time must be after " + newDate);
|
|
|
|
|
 |
You seem to have forgotten to ask a question.
You've told us what you want to do; you've shown us the code you've got; but you haven't told us what the problem is.
If you're getting an error, post the full details of the error, and tell us which line of code it's thrown from.
If it's not doing what you want, tell us what the inputs are, and describe what it's actually doing.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
 |
I want to convert HTML div into image by java script.
|
|
|
|
|
 |
Currently I am having one url with www.domainname/countrycode
1.at present my countrycode is default lets say Uk.
2.my requirment is according to my country location my url should append with countrycode.
Ex: if I type url from India ---> www.domainname.com/in
from UK --> www.domainname.com/uk
|
|
|
|
 |
You also posted this in the asp.net forum, you should at least know what technology you want the solution to use so that someone can help you.
|
|
|
|
 |
And in the C# forum as well.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
 |
Why have you replied to me, rather than the OP?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
I need help trying to debug this script, as it doesn't work.
<p align="center"> <textarea id="xclToTw" rows="20" cols="60"></textarea><br /> <button onclick="(function(){var ta=document.getElementById('xclToTw'); displayMessage('original: ' + ta.value); ta.value=ta.value.replace(/^|$|\t/gm, '|');})();" > Translate</button> </p>
It is supposed to let me paste spreadsheet cells from google sheets and translate them so that they are delimited by a |
as in
one two three four five six
should yield
|one|two |three| |four|five|
|
|
|
|
 |
The regular expression you're using is looking to replace tabs. The sample input you've provided doesn't use tabs; it uses spaces.
If the columns will always be separated by at least two spaces, use:
/^|$|\t|\s{2,}/gm
If the columns will always be separated by at least one space, and will never contain a space, use:
/^|$|\t|\s+/gm
If you can't guarantee either one of those conditions, then there's no way to differentiate between a space within a column and a space between two columns.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
Hello - this is my first code so please be patient. I am using Google Apps Script in a google sheet . . .but I get an error . .I am trying to extract the full name from the email address . . .
function onOpen() {
var MyName = Session.getActiveUser()
var myvar = MyName.slpit("@");
Browser.msgBox('Welcome to my spreadsheet '+MyName, Browser.Buttons.OK);
}
|
|
|
|
 |
- You've spelt "split" as "slpit" which will cause an error.
- The split() method returns an array of string objects, not a simple string, so your msgBox needs to reference one of those - in your case myvar[0]
modified 17-Jan-16 19:08pm.
|
|
|
|
 |
Thank You, Wombaticus! I corrected the spelling, but I am afraid I am not sure how to follow your second instruction? How do I do that in the code, please?
|
|
|
|
 |
Browser.msgBox('Welcome to my spreadsheet '+myvar[0], Browser.Buttons.OK);
modified 17-Jan-16 19:09pm.
|
|
|
|
 |
Wombaticus . .okay so this is what I have . .but I still receive an error . . .
function onOpen() {
var MyName = Session.getActiveUser()
var myvar = MyName.split("@");
Browser.msgBox('Welcome to my spreadsheet '+myvar[0], Browser.Buttons.OK);
}
|
|
|
|
 |
Are you sure Session.getActiveUser() is returning a string (i.e. is not 'undefined')?
Otherwise, I don't know I'm afraid. (And I have to go now - sorry.)
|
|
|
|
 |
Try wrapping your code in a try..catch block to catch the error and find out exactly where/what it is.
|
|
|
|
 |
Wombaticus - your last message helped me correct it . . .you were right getActiveUser() was not returning a string . . THANKS!!!
var MyName = Session.getActiveUser().getEmail()
|
|
|
|
 |
Member 12269518 wrote: but I still receive an error . . .
If you want us to help you fix an error, it would help if you told us what that error is.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
Hi,
I have a google map with dropdown menu contains map and statellite. When we hover on it will show Change map style. How to change to our own text instead of Change map style.
google.maps.MapTypeControlStyle.DROPDOWN_MENU used to show dropdown.
How to achive this. If anybody knows, please reply me.
Thanks in advance.
|
|
|
|
 |
How does a multidimensional array works? Is the below code similar?
var people = [
["","","",],
["","","",],
["","","",],
["","","",]
];
|
|
|
|
|
 |
Your layout isn't terribly meaningful for illustration. Basically they are indexed from outermost to innermost:
var array = [
['thing1','stuff1'],
['thing2','stuff2'],
['thing3','stuff3'],
]
Will result in:
array[0] === ['thing1','stuff1'];
array[0][0] == 'thing1';
array[0][1] == 'stuff1';
array [2][1] == 'stuff3';
And since strings are arrays:
array[0][0][0] === 't';
array[0][0][1] === 'h';
array[0][0][2] === 'i';
array[0][0][3] === 'n';
array[0][0][4] === 'g';
array[0][0][5] === '1';
And there's your 10 second multi-dimensional array tutorial.
|
|
|
|
 |
Hello,
I am trying to make a countdown clock and I want to start with a time (5:00 minutes) and from there press a submit button to start the countdown. I have no idea where to start. I am using javascript to code my countdown clock.
|
|
|
|
|
 |
I am looking to achieve the following effect in a mobile browser using HTML and JavaScript.
Firstly, the browser will show a facsimile of a complicated page consisting of sections, columns etc, a bit like, say, the page of a broadsheet newspaper. This facsimile will fit in its entirety on the screen.
From here, I want a single tap on a particular section of the page to zoom in on that section, causing it to fill the entire screen width.
It should then be possible to navigate from one portion of the screen to the other by dragging up/down/left/right. Does anyone know of any technique/tool/library to achieve this?
I should mention that the paragraphs/columns/etc are identifiable divs.
|
|
|
|
 |
Sure, just use the tools in whatever framework you're using (or vanilla) to hide the divs that aren't selected, set the selected to 100%/100%, and to change the selection based on drag direction. Just a couple of event handlers and you're there.
Pick a library, write a treatment, and I'm sure everyone will gladly help from there.
|
|
|
|
 |
I want to load all the images from a folder on local by using Jquery/Javascript.
Please help me.
Thanks you!
|
|
|
|
 |
Where are you stuck?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
 |
I'm new in Javascript web applications, I'm more used to creating java/Spring c#/.Net applications, I'm also not a guru in those, though.
What I always do when I create a web application using MVC pattern I do the following:
I create the following folders to organize my code
-View folder: here I put all the HTML files
-Controller folder: here I put all my methods that call the necessary methods to bring me the data that's needed in the views.
-Service folder: here I put all the methods that go to the database to bring info and other necessary methods from the business logic.
-Model folder: here I put all my classes with the attributes example (User class, Role class, Vehicle class, etc).
Example:
public class User {
private name;
.....
getters and setters...
}
I want to apply the same or a similar concept to my Javascript/AngularJS tutorial learning app
So far I have created a very simple app a calculator app with the Service Layer, Controller Layer and View Layer and they work as I expected to work,
the service layer: have all the methods like add, subtracts, multiply.
the view layer: have the html where I input the numbers.
the controller layer: have the method that calls the service and then I pass the data to the view.
BUT my problem is that I don't know how the Model fits in a AngularJS app I have see that some tutorials put the model objects inside the controllers like this
app.controller('BookController', ['$scope', function($scope) {
$scope.book = {
id: 1,
name: 'Harry Potter',
author: 'J. K. Rowling',
stores: [
{ id: 1, name: 'Barnes & Noble', quantity: 3},
{ id: 2, name: 'Waterstones', quantity: 2},
{ id: 3, name: 'Book Depository', quantity: 5}
]
};
}]);
but I don't know if that's the way because if I need a model object in another controller do I need to declare the same code in the other controller??
Also how should I deal with model objects that have inside other model object lets say Users have roles inside them.
where should I put my model objects like User, Role, Vehicle etc? Is there a good approach if I create a .JS file named model.js and put there all the objects like this:
function Apple (type) {
this.type = type;
this.color = "red";
}
Apple.prototype.getInfo = function() {
return this.color + ' ' + this.type + ' apple';
};
But I have read about the global scopes and bad practices etc I actually don't know too much about that if I create that file model.js with my model objects would I be creating a problem?
I'm very open to suggestions since I'm learning
|
|
|
|
 |
There's a problem with terminology that you need to wrap your head around before you can really dig in with Angular. The primary issue is that what Angular calls a controller, most everyone else would call a ViewModel (part of why they advertise it as MV-Whatever). More precisely, the $scope on a specific controller is the model that is bound to the interface.
A better way to think of model generation in angular is to consider the prototype/instance relationship. You don't need to reinvent the wheel (or re-implement an object) every time you fire up a $scope. Instead, you can leverage either the service or factory providers to provide the prototypes. Use a service when you need something that has a state to maintain, and use a factory for new, fresh objects.
what I wouldn't do is use vanilla JS definition and prototyping to define objects. This will put them outside of the normal Angular digest cycle, they will not be registered through a provider, and you might find they do not behave as expected. You'll also be skipping out on Dependency Injection, which would be a shame.
For instance:
myApp.factory('appleFactory',[function(){
return {
new : function(type){
return { type : type, color: 'red' };
}
}
}]);
myApp.controller('getMoreApplesController',['$scope','appleFactory',function($scope, Apple){
$scope.firstApple = Apple.new('Golden Delicious');
$scope.secondApple = Apple.new('Washington Red');
}]);
|
|
|
|
|
 |
If you need to take multiple information, I would suggest to have a set of text boxes in a page itself instead.
If you need the prompt only, you need to re call the prompt again in loop for all your needed information.
Life is a computer program and everyone is the programmer of his own life.
|
|
|
|
 |
Thank you so much. I was able to figure it out.
|
|
|
|
 |
Try this but i not sure is this what u wanted, as it have same as title and the need u described !!
in this site on Prompt Box http://www.w3schools.com/js/js_popup.asp
|
|
|
|
 |
Thank you so much. I figured it out.
|
|
|
|
 |
No, You can't do this. As prompt() is the in built function of JavaScript. So, you can't modify that.
But you can make your own dialogue box not prompt.
|
|
|
|
 |
Hi,
I am using Javascript to open the popup in new window but it is opening as a new tab in IE11.
Same code is working in Chrome and get popup in new window but not in IE11 windows 7.
How to achieve this.
If anybody knows please reply me.
Thanks in advance.
|
|
|
|
 |
Please note that the popup behavior depends on browser settings.
Please check browser settings, if popup is allowed or not.
Additionally, please provide what code you have used to open the popup so that you can be helped further.
Life is a computer program and everyone is the programmer of his own life.
|
|
|
|
 |
Post your code.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
 |
Need code on java to integrate fingerprint to php
|
|
|
|