what is wrong with this baby-simple code, please?

Discussion in 'JavaScript' started by ranchobob, Mar 2, 2007.

  1. #1
    I'm trying to view it in IE6

    <script type="text/javascript">
    function woikit() {
    var months = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
    var days = new Array("Sunday","Monday","Tuesday","Wednsday","Thursday","Friday","Saturday");
    var c1 = new Date();
    var c2 = new Date();
    
    alert("got here")
    c1.setmonth(document.form1.dat1.value);
    c1.setday(document.form1.dat2.value);
    c1.setyear(document.form1.dat3.value);
    alert(c1);
    }
    
    </script>
    Code (markup):
    the alert "got here" fires, so I know i made it from the submit button to the function.

    but alert(c1) does not work.

    Am I failing to see the alert, or failing to get the input data into the date vars?

    I use this button to start it;

    <input type="submit" name="Submit" value="Submit" onClick="woikit()">
    Code (markup):
    I appreciate your time and help....
     
    ranchobob, Mar 2, 2007 IP
  2. rgchris

    rgchris Peon

    Messages:
    187
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    c1.setmonth(document.form1.dat1.value);
    c1.setday(document.form1.dat2.value);
    c1.setyear(document.form1.dat3.value);
    Code (markup):
    Are those supposed to be "date" instead of "dat"?
     
    rgchris, Mar 2, 2007 IP
  3. Aragorn

    Aragorn Peon

    Messages:
    1,491
    Likes Received:
    72
    Best Answers:
    1
    Trophy Points:
    0
    #3
    The method names are case sensitive
    
    c1.[B]setMonth[/B](document.form1.dat1.value);
    c1.[B]setDay[/B](document.form1.dat2.value);
    c1.[B]setYear[/B](document.form1.dat3.value);
    
    Code (markup):
     
    Aragorn, Mar 2, 2007 IP
  4. datropics

    datropics Peon

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Aragorn is correct - the method names are case sensitive - advise if you still having an issue
     
    datropics, Mar 2, 2007 IP
  5. ranchobob

    ranchobob Guest

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I got this form this url

    http://richardbowles.tripod.com/javascript/section8/lesson8.htm

    And this is borne out in Dreamweaver where setMonth and SetYear are given a green font color indicating keywords, and SetDay remains unchanged.

    I used SetMonth - getDay - setYear and got a date and time value back in the alert.

    Thank you so much for your input.
    Next I will try to subtract dates, and assign different hotel rates to weekday and weeknights, then add up the values and average them

    Good clean fun.
     
    ranchobob, Mar 2, 2007 IP