473,322 Members | 1,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Why my javascript cant work?

65
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4.   <title>Testing date function on 8 oct 2007</title>
  5.   <script language="Javascript" src="menu/calender/CalendarPopup.js"></script>
  6.   <script language="Javascript" src="menu/calender/AnchorPosition.js"></script>
  7.   <script language="Javascript" src="menu/calender/date.js"></script>
  8.   <script language="Javascript" src="menu/calender/PopupWindow.js"></script>
  9.  
  10.   <script language="Javascript">
  11.    function calDate(downdate,podate,duration) {
  12.     //alert("You can"+downdate+"You can"+podate+"You can"+duration)
  13.  
  14.     var myDate = new Date()
  15.     var result = myDate.setDate(myDate.getDate()+duration)
  16.     //var myDate = downdate
  17.  
  18.     alert(result)
  19.    }
  20.   </script>
  21. </head>
  22.  
  23. <body>
  24.   <form>
  25.  
  26. <script language="Javascript">
  27. var cal1 = new CalendarPopup();
  28. </script>
  29.  
  30. PO Receive Date:&nbsp;<input type="text" name="date2" value="" size=25>
  31. <a href="#" onClick="cal1.select(document.forms[0].date2,'anchor2','dd-MMM-yyyy'); return false;" name="anchor2" id="anchor2">Select</a>
  32.  
  33. <br/>
  34.  
  35. Downpayment Date:&nbsp;<input type="text" name="date1" value="" size=25>
  36. <a href="#" onClick="cal1.select(document.forms[0].date1,'anchor1','dd-MMM-yyyy'); return false;" name="anchor1" id="anchor1">Select</a>
  37.  
  38. <br/>
  39.  
  40. Estimate Duration:&nbsp;<select name="duration" onChange="calDate(document.forms[0].date1.value,document.forms[0].date2.value,document.forms[0].duration.value)">
  41.                          <option value="">--
  42.                          <option value="1">1
  43.                          <option value="2">2
  44.                          <option value="3">3
  45.                          <option value="4">4
  46.                          <option value="5">5
  47.                          <option value="6">6
  48.                          <option value="7">7
  49.                          <option value="8">8
  50.                          <option value="9">9
  51.                          <option value="10">10
  52.                         </select> Week(s)
  53.  
  54. <br/>
  55.  
  56. Estimate Completion Date:&nbsp;<input type="text" name="dateest" value="" size=25>
  57.  
  58. <br/>
  59.  
  60. Warranty Date:&nbsp;<input type="text" name="datewarranty" value="" size=25>
  61.  
  62. <br/>
  63.  
  64. Shipment Date:&nbsp;<input type="text" name="dateship" value="" size=25>
  65. <a href="#" onClick="cal1.select(document.forms[0].dateship,'anchorship','dd-MMM-yyyy'); return false;" name="anchorship" id="anchorship">Select</a>
  66.  
  67.   </form>
  68. </body>
  69. </html>
  70.  
Hi,
Why my javascript produce funny output to me? Can someone guide me how to calculate the advance date based on the duration from the select box? And the output should pass value in the estimate date input box and not the alert msg box.I use alert msg box for testing purpose.

Thanks.

Can someone told me how to use the code tag in this forum?
Oct 8 '07 #1
10 1416
dmjpro
2,476 2GB
What's wrong happening with you ???

Debasis Jana
Oct 8 '07 #2
wish
65
Hi,

I wan to calculate date in advance based on the user choice the date from the downpayment date and duration. I use the javascript to calculate and put the advance date in estimate completion date input box but the javascript cant work. It comes out result with a long integer. Can you guide me?

Thanks.
Oct 9 '07 #3
dmjpro
2,476 2GB
Hi,

I wan to calculate date in advance based on the user choice the date from the downpayment date and duration. I use the javascript to calculate and put the advance date in estimate completion date input box but the javascript cant work. It comes out result with a long integer. Can you guide me?

Thanks.
Oh ... I see.
You have the total milliseconds since 1970-1st-January.
Have a look at this.
It may help you.
Have a careful read on it :-)

Debasis Jana
Oct 9 '07 #4
wish
65
Expand|Select|Wrap|Line Numbers
  1. function y2k(number) { return ( number<1000 ) ? number+1900:number; }
  2.  
  3. function add_days(adate,days){
  4.   return new Date (adate.getTime()=(days*86400000));
  5. }
  6.  
  7. function format_date(adate){
  8.   return adate.getDate()+'/'+(adate.getMonth()+1)+'/'+y2k(adate.getYear());
  9. }
  10.  
  11. function show_dates(adate){
  12.   var then = add_days(now,7);
  13.   var begin = format_date(now);
  14.   var end = format_date(then);
  15.   document.write(begin+'-'+end+'<br>');
  16. }
  17.  
  18. var now = new Date(2007,10-1,27);
  19.  
  20. for (var i=0; i<2; i++){
  21.   show_dates(now);
  22.   now = add_days(now,7);
  23. }
  24.  
the above code will generate the output like this;

27/10/2007-3/11/2007
3/11/2007-10/11/2007

can someone guide me to edit this javascript to make it what i wan?

1) I would like to pass variable into javascript by the date that selected and duration by user. where should i to edit it?

2) I wan that user choice the duration (e.g 2 weeks) then pass to generate the date in advance by 2 weeks and call the function to calculate and i dun wan the function auto calculate to me when i haven pass the value in.

3) the output is 10/11/2007, the less of the output i no need and i would like to put this 10/11/2007 inside the estimate completion date.

Thanks in advance.
Oct 9 '07 #5
dmjpro
2,476 2GB
Have a change this function.

Expand|Select|Wrap|Line Numbers
  1. function add_days(adate,days){
  2.   //return new Date (adate.getTime()=(days*86400000));
  3.   return adate.setDate(adate.getDate()+days);
  4. }
  5.  
Debasis Jana
Oct 9 '07 #6
wish
65
Hi dmjpro,

the above change code will effect any thing? I try it but the result is nothing..
Oct 9 '07 #7
dmjpro
2,476 2GB
Hi dmjpro,

the above change code will effect any thing? I try it but the result is nothing..
Post here the total code you tried so far.
And tell me what's your expected Output and what you are getting now.

Debasis Jana
Oct 9 '07 #8
wish
65
HI,

1)I wan pass in the duration from the select box to the for loop so i can calculate the date in advance based on the user select.

2)I wan pass in the date from downpayment date to the
Expand|Select|Wrap|Line Numbers
  1. var now = new Date (2007,10-1,27)
instead of default it.

3)I only wan this function calculate the date advance when i finish choice the duration in select box.

4)The output of this date in advance should print out in the "Estimate Completion Date".

Can u guide me the above four items.Thanks.
Oct 10 '07 #9
dmjpro
2,476 2GB
HI,

1)I wan pass in the duration from the select box to the for loop so i can calculate the date in advance based on the user select.

2)I wan pass in the date from downpayment date to the
Expand|Select|Wrap|Line Numbers
  1. var now = new Date (2007,10-1,27)
instead of default it.

3)I only wan this function calculate the date advance when i finish choice the duration in select box.

4)The output of this date in advance should print out in the "Estimate Completion Date".

Can u guide me the above four items.Thanks.
Expand|Select|Wrap|Line Numbers
  1. var now = new Date (2007,10-1,27);
  2.  
This Code is not working?

Debasis Jana
Oct 10 '07 #10
wish
65
Thanks..i already solved.
Oct 10 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: NecroJoe | last post by:
I am using PHP to generate a little javascript for one of my pages. In short it allows a user to select a value from a list and pop it into a form field on a seperate page. This works well unless...
1
by: Silvia Brunet-Jones | last post by:
Ok I am about to pull my hair. I have an active x control in an object tag which, as you know cant have runat=server. So what I need is to not loose what is in this box everytime a postback...
6
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
11
by: Nathan Sokalski | last post by:
I add several JavaScript events (onchange, onkeypress, etc.) to Controls using the Add method of the Attributes collection. However, if the JavaScript code contains certain characters, such as & or...
1
by: TKapler | last post by:
I think i am quite experienced javascript programmer, but I got a problem. I have a selectbox with e.g. 17 optgroups with 100 options. I need a javascript code to hide some of that optgroups (i...
36
by: Mark Rae | last post by:
Hi, Just had an interesting message from someone who was unable to view one of my sites because they have JavaScript turned off, and expecting me to re-write my site so that they could view...
1
by: wkerplunk | last post by:
Below is what I have build with several different languages. It works great but I need help, I am stuck. When you click on an item in the dropdown autocomplete div it does a mousedown function...
4
by: kang jia | last post by:
hi now i am using javascript to do a "flexiable" validaion, what i mean "flexiable" is user can choose which one they would like fill in in the bank but at least they must enter one. in my page,...
3
by: rassklass | last post by:
HI all, I have designed a site found at www.pickupnewspapers.co.uk/nottinghamshire/index.html but I cant get the footer to sit stil on the page. It is because of the javascript ticker, everytime...
10
by: happyse27 | last post by:
Hi all, I have enabled Javascripting in internet explorer 7, and I have been writing script in perl. The thing I cant do now is to pop up image in small html frame from main html page.......
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.