Results 1 to 6 of 6

Agree Before Entry

This is a discussion on Agree Before Entry within the Programming forums, part of the Web Designing & Development category; This handy script lets you auto-generate the day and year in a dropdown selection as well as validate the date. ...

  1. #1
    Junior Member
    Join Date
    Mar 2009
    Location
    JavaScriptBank.com - Free JavaScript Source Code
    Posts
    14

    Default Agree Before Entry

    This handy script lets you auto-generate the day and year in a dropdown selection as well as validate the date. Add it to your pages that require detail



    [SIZE=4]How to setup[/SIZE]

    Step 1: Use JavaScript code below to setup the script
    JavaScript
    Code:
    <Script Language="JavaScript">
    function populate(inForm)
    {
    var temp=0;
    var today= new Date();
    var day= today.getDate();
    var month= today.getMonth();
    var year= today.getFullYear();
    t2= prompt("Enter the number of years to fetch",1);
    
    
    
    for (var i=0; i <31 ; i++)
        {
        var x= String(i+1);
        
        inForm.day.options[i] = new Option(x,x);
        }
    
    for (var i=0; i <31 ; i++)
        {
        var d=0;
        d=inForm.day.options[i].value;
        if(d=day){
            inForm.day.options[i].selected=true;
            break;}
        }
    
    for (var i=0,j=year; i <t2 ; i++, j--)
        {
        var y= String(j);
        inForm.year.options[i] = new Option(y,y);
            
        }
    for(var i=0;i<12;i++)
        {
        
        if(i=month)
            {inForm.month.options[i].selected=true;
        break;}
        
        }
    
    }
    
    function populate2(inForm2)
    {
    var t3=0;
    
    
    if(inForm2.month.options[1].selected)
    
    t3=28;
    else if(inForm2.month.options[8].selected||inForm2.month.options[3].selected||inForm2.month.options[5].selected||inForm2.month.options[10].selected)
    t3=30;
    else
    t3=31;
    
    
    for(i=0;i<31;i++){
    inForm2.day.options[i]=null;
    }
    
    for (var i=0; i <t3 ; i++)
        {
        var x= String(i+1);
        inForm2.day.options[i] = new Option(x);
            
        }
    }
    </script>
        <!--
            This script downloaded from w w w.JavaScriptBank. com
            Come to view and download over 2000+ free javascript at w w w.JavaScriptBank. com
        -->
    Step 2: Place HTML below in your BODY section
    HTML
    Code:
    <BODY onLoad=populate(form1)>
    <FORM NAME="form1">
    <p>
    <b>Day</b>  <SELECT NAME="day"></SELECT>  
    
       <b>Month</b>    <SELECT NAME="month" onChange = populate2(form1)>
    <Option value=0>January</Option>
    <Option value=1>February</Option>
    <Option value=2>March</Option>
    <Option value=3>April</Option>
    <Option value=4>May</Option>
    
    <Option value=5>June</Option>
    <Option value=6>July</Option>
    <Option value=7>August</Option>
    <Option value=8>September</Option>
    <Option value=9>October</Option>
    <Option value=10>November</Option>
    <Option value=11>December</Option>
    </SELECT>
    
        <b>Year</b><SELECT NAME="year"></SELECT>
    
    </FORM>
    </body>
        <!--
            This script downloaded from w w w.JavaScriptBank. com
            Come to view and download over 2000+ free javascript at w w w.JavaScriptBank. com
        -->

  2. #2
    Senior Member kundu's Avatar
    Join Date
    Jun 2007
    Posts
    147

    Default Re: Agree Before Entry

    Thanks for sharing this script.

  3. #3
    Member
    Join Date
    Sep 2009
    Posts
    56

    Default Re: Agree Before Entry

    Well the script is good I will use it in my future code if it will be required

  4. #4
    Senior Member orlando's Avatar
    Join Date
    Sep 2008
    Posts
    113

    Default Re: Agree Before Entry

    Thanks for sharing this code.

  5. #5
    Junior Member
    Join Date
    Mar 2009
    Location
    JavaScriptBank.com - Free JavaScript Source Code
    Posts
    14

    Default Re: Agree Before Entry

    no problem, I hope this code will be useful for someone

  6. #6
    Senior Member
    Join Date
    Mar 2011
    Posts
    110

    Default Re: Agree Before Entry

    Thanks a lot for sharing such a nice and useful coding............