|
Hi,
I pasted the function source from my post above into a webpage and tested the scenario you mentioned, but, oddly enough, I didn't have the same problem. Maybe check to see if your function is identical to the one I posted above and then, if that doesn't work, give me the exact code where you invoke the function.
I will look at DateVariance when I have a chance.
Sincerely,
Alexander Wiseman
|
|
|
|
|
First I found that javascript function getMonth() always starts from zero
I copied it as it is from the above reply!
This is the place where I am calling it
FormatDate(AddDayToDate(FormatDate(document.frmEngine.PLREMDATE.value,"yyyy/mm/dd"), 0), "dd/mm/yyyy") ;
function AddDayToDate(plandate, days)<br />
{<br />
var gCurrentDate = new Date(plandate)<br />
<br />
var newDate = DateAdd(gCurrentDate, parseInt(days,10), <br />
parseInt(0,10), <br />
parseInt(0,10)); <br />
<br />
var year = newDate.getFullYear() ; <br />
var month = newDate.getMonth() ;<br />
var date = newDate.getDate() ;<br />
return date + "/" + month + "/" + year ;<br />
}
function FormatDate(DateToFormat,FormatAs)<br />
{<br />
if(DateToFormat=="")<br />
{<br />
return"";<br />
}<br />
<br />
if(!FormatAs){FormatAs="dd/mm/yyyy";}<br />
<br />
var strReturnDate;<br />
<br />
FormatAs = FormatAs.toLowerCase();<br />
<br />
DateToFormat = DateToFormat.toLowerCase();<br />
<br />
var arrDate<br />
<br />
var arrMonths = new Array("January","February","March","April","May","June","July","August","September","October","November","December");<br />
<br />
var strMONTH;<br />
<br />
var Separator;<br />
<br />
while(DateToFormat.indexOf("st")>-1)<br />
{ <br />
DateToFormat = DateToFormat.replace("st","");<br />
}<br />
<br />
while(DateToFormat.indexOf("nd")>-1)<br />
{<br />
DateToFormat = DateToFormat.replace("nd","");<br />
}<br />
<br />
while(DateToFormat.indexOf("rd")>-1)<br />
{<br />
DateToFormat = DateToFormat.replace("rd","");<br />
}<br />
<br />
while(DateToFormat.indexOf("th")>-1)<br />
{<br />
DateToFormat = DateToFormat.replace("th","");<br />
}<br />
<br />
if(DateToFormat.indexOf(".")>-1)<br />
{<br />
Separator = ".";<br />
}<br />
<br />
if(DateToFormat.indexOf("-")>-1)<br />
{<br />
Separator = "-";<br />
}<br />
<br />
<br />
if(DateToFormat.indexOf("/")>-1)<br />
{<br />
Separator = "/";<br />
}<br />
<br />
if(DateToFormat.indexOf(" ")>-1)<br />
{<br />
Separator = " ";<br />
}<br />
<br />
arrDate = DateToFormat.split(Separator);<br />
DateToFormat = "";<br />
<br />
for(var iSD = 0;iSD < arrDate.length;iSD++)<br />
{<br />
if(arrDate[iSD]!="")<br />
{<br />
DateToFormat += arrDate[iSD] + Separator;<br />
}<br />
}<br />
<br />
DateToFormat = DateToFormat.substring(0,DateToFormat.length-1);<br />
arrDate = DateToFormat.split(Separator);<br />
<br />
if(arrDate.length < 3)<br />
{<br />
return "";<br />
}<br />
<br />
var DAY = arrDate[0];<br />
var MONTH = arrDate[1];<br />
var YEAR = arrDate[2];<br />
<br />
if(parseFloat(arrDate[1]) > 12)<br />
{<br />
DAY = arrDate[1];<br />
MONTH = arrDate[0];<br />
}<br />
<br />
if(parseFloat(DAY) && DAY.toString().length==4)<br />
{<br />
YEAR = arrDate[0];<br />
DAY = arrDate[2];<br />
MONTH = arrDate[1];<br />
}<br />
<br />
<br />
for(var iSD = 0;iSD < arrMonths.length;iSD++)<br />
{<br />
var ShortMonth = arrMonths[iSD].substring(0,3).toLowerCase();<br />
var MonthPosition = DateToFormat.indexOf(ShortMonth);<br />
if(MonthPosition > -1)<br />
{<br />
MONTH = iSD + 1;<br />
if(MonthPosition == 0)<br />
{<br />
DAY = arrDate[1];<br />
YEAR = arrDate[2];<br />
}<br />
break;<br />
}<br />
}<br />
<br />
var strTemp = YEAR.toString();<br />
<br />
if(strTemp.length==2)<br />
{<br />
if(parseFloat(YEAR)>40)<br />
{<br />
YEAR = "19" + YEAR;<br />
}<br />
else<br />
{<br />
YEAR = "20" + YEAR;<br />
}<br />
}<br />
<br />
<br />
if(parseInt(MONTH)< 10 && MONTH.toString().length < 2)<br />
{<br />
MONTH = "0" + MONTH;<br />
}<br />
<br />
if(parseInt(DAY)< 10 && DAY.toString().length < 2)<br />
{<br />
DAY = "0" + DAY;<br />
}<br />
<br />
switch (FormatAs)<br />
{<br />
case "dd/mm/yyyy":<br />
return DAY + "/" + MONTH + "/" + YEAR;<br />
case "mm/dd/yyyy":<br />
return MONTH + "/" + DAY + "/" + YEAR;<br />
case "dd/mmm/yyyy":<br />
return DAY + " " + arrMonths[MONTH -1].substring(0,3) + " " + YEAR;<br />
case "mmm/dd/yyyy":<br />
return arrMonths[MONTH -1].substring(0,3) + " " + DAY + " " + YEAR;<br />
case "dd/mmmm/yyyy":<br />
return DAY + " " + arrMonths[MONTH -1] + " " + YEAR; <br />
case "mmmm/dd/yyyy":<br />
return arrMonths[MONTH -1] + " " + DAY + " " + YEAR;<br />
case "yyyy/mm/dd":<br />
return YEAR + " " + arrMonths[MONTH -1] + " " + DAY ;<br />
}<br />
<br />
return DAY + "/" + strMONTH + "/" + YEAR;;<br />
<br />
}
Regards,
The Phantom.
|
|
|
|
|
Hey,
I have looked through your code and discovered why the month is being decreased by 1. You were exactly right when you said that the getMonth() function returns the zero-based index of the month. Your formatting functions assume a one-based index of the month, which means that the when you call FormatDate after the call to AddDayToDate , the month gets set back by 1 (July becomes June, in your test scenario).
Fortunately, there is an easy way to fix this and I have tested it to make sure it works. You need to modify the AddDayToDate function to add one to the month returned by getMonth . Below you will find the modified version of AddDayToDate . Copy it into your code and it should work fine.
function AddDayToDate(plandate, days)
{
var gCurrentDate = new Date(plandate);
var newDate = DateAdd(gCurrentDate, parseInt(days,10),
parseInt(0,10),
parseInt(0,10));
var year = newDate.getFullYear() ;
var month = newDate.getMonth() + 1 ;
var date = newDate.getDate() ;
return date + "/" + month + "/" + year ;
}
Hope that helps! Let me know if it still doesn't work. Also, I haven't had a chance, but I plan to work on the DateVariance function. I already know how to go about it, so it will just be a matter of sitting down and writing the code when I have a free moment.
Sincerely,
Alexander Wiseman
|
|
|
|
|
Alex,
It worked.
5 stars for you
Please, look for the day variance as I am loosing my patience
Thanks.
Regards,
The Phantom.
|
|
|
|
|
|
Dear people,
I have been searching for the correct code to call upon a webservice directly from an aspx page.
Can anyone tell me how to do it?
|
|
|
|
|
wherever you need to call a web service, it is same. add a web reference to the asmx, which will create a proxy class for you. Then just make calls to methods as if the Web service is local to you.
Bhaskara
|
|
|
|
|
Let us say you created web service with some web method called
foo(). Now you create a web page in a new project from which you want to call this web service.
The first thing you need to do is to add a web reference to the Reference node of your project. This opens up a wizard where you need to reference your .asmx or .wdl url reference. Once you do this, you have the localhost( your local website)with the web service ready.
Add a button to your page. In the click event you need to create the following code. Before you write this code, at the top of the page, you need to add:
imports localhost.service1
in the click event add the following code:
dim mysvc as new service1
document.write(mysvc.foo())
ps;The service1 is having the method foo() when you created the web service. I will try to write a codewalk on this next time to the CodeProject.
|
|
|
|
|
How do I shutdown a webserver from a browser page with frames
Senthil
|
|
|
|
|
Could you be more specific with this? Are you using ASP or ASPX?
~javier lozano
(blog || email)
|
|
|
|
|
Hi
The server is a java application
Scripts used are javascript. The page has frames
Best
Senthil
|
|
|
|
|
still a little vague...
~javier lozano
(blog || email)
|
|
|
|
|
How to collect garbage in JS effectively?
i came across a function CollectGarbage in JS which can do the task but the article says that it is undocumented and in testing. That article was of May 2001. but the function is stil there in IE6. Anyone who know consequences of using CollectGarbage or have ever used the function
Regards
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
AWS Report for OpenListing
---------------------------------
Hi..
Can any one help me Generate & Get Open Listing report in Amazon Web Services (AWS)
Just need steps..
Thanks
Never consider anything Impossible before trying to solve that..---Sumit Kapoor--- sumit_kapoor1980@hotmail.com
|
|
|
|
|
hey if you get the code please let me know as well
ZAK
|
|
|
|
|
Suppose you have a web server which is completely dumb, and a client which is served a webpage from that server.
The client opens a socket and sends commands to the server. This works very well with java, but we need to use a handheld pc such as a Palm Tungsten, which doesn't have a java enabled browser...
The web server just serves pages, it's completely dumb in that respect, no ASP, no PHP, no perl, nothing spiffy and useful like that.
|
|
|
|
|
yeah...what about it? All do is send simple HTTP request to this server and get databack. It's not that hard, I've done it before with my pocket pc...why you ask about this?
Here's one for quicks:
on your PC open a command window (cmd.exe), then type the following:
<br />
telnet www.codeproject.com 80<br />
after the screen goes blank type the following:
<br />
GET / <br />
hit <Enter> twice...
There you have it, a simple HTTP request.
~javier lozano
(blog || email)
|
|
|
|
|
I want to make a select box in a Javascript function, this is my code:
var val = new Array('0','1','2','3','4','5');
var lis = new Array('java','php','asp','jsp','vbscript','jscript');
function makeOption(obj,selectID)
{
obj.options[0] = new Option(lis[0],val[0],false,false)
for(i=1;i<lis.length;i++)
if (val[i]==selectID){
obj.options[i] = new Option(lis[i],val[i],false,true);
}
else{
obj.options[i] = new Option(lis[i],val[i],false,false);
}
}
var selectID = 3
makeOption(document.form1.ProgramList,selectID);
The trouble is in Netscape the selectlist can't make selected with selectID("asp"), the selectlist its always select the first item "java". But this code run correct in IE.
Is Anybody can help me, please? Thanks for all response!
|
|
|
|
|
I have a table layout that uses CSS to format the background color of the cells, etc. The problem is when I use any of the border styles, the space for the border is drawn, but not the color. (i.e. if I have border-bottom: solid 1px black; it I get a 1 px, solid WHITE border. I have tried many colors and it always ends up white. I also changed the width to something big, like 10px, and once again, I got a 1px, WHITE border. Any ideas???
There's a fine line between confidence and arrogance.
|
|
|
|
|
Hi,
What browsers are you using to render the HTML? Also, are you setting the class at the table level or the cell level.
I don't seem to have any problems using IE6. Can you post the HTML of the table + defined CSS that you are using.
Cheers,
Andy
|
|
|
|
|
Hi,
I am trying divide my display into pages.i.e if there are 400 records then if I display 10 records in 1 page,I have 40 pages.Now I have certain conditional sql statements for which I have to retain the values of the dropboxes from which I select the Author,Name and Title of the book with the following code.
if request("ACTION")="Submit" then
for i = 1 to Request.Form.Count
'if Request.Form.Key(i)<>"ACTION" then
iname = Request.Form.Key(i)
ival = Request(iname)
if i>1 then filterIS = filterIS & "&"&iname&"="&ival else filterIS="&"&iname&"="&ival
next
session("filterIS")= filterIS
end if
but now this session variable is lost when I click on different page nos on my page.
%><%=x%><%
Please tell me how do I retain the value of filterIS so that the records for respective pages are displayed.
Thanks
|
|
|
|
|
I have read articles explaining how to host a .NET Windows Form within IE and I have a general question that perhaps someone can answer and save me some research. Once a .NET control has been constructed within IE, can this control communicate back to the HTML page that is hosting it? Can I push a button within the .NET control, and have C# code find an HTML element on it's parent page and perform an operation on it (change its color or update its value)?
If that's possible, is the reverse possible? Can a javascript operation on an HTML button, call a method within that .NET control that it's hosting? If these things are possible, can you point me to where I need to look to implement these behaviors?
Thank you in advance for any input.
-Ron Ward
|
|
|
|
|
|
Thank you for the article...that is a big help.
|
|
|
|
|
hi all,
kindly someone explain the process and coding as to how to download a file from client to server,as we generally do in attaching files thru mail
|
|
|
|
|