Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question String together input from a form to create a URL

    I'm new to JavaScript. I created a simple HTML page on our LAN, and I am trying to create a link from this page to a daily spreadsheet (YYYYMMDD.xls) on the same LAN. I want to create a form with three input boxes (yyyy, mm, dd) that the user can submit in order to open older versions of the document. We use the following script to open the current document:

    <script>
    var date = new Date();
    var d = date.getDate();
    var day = (d < 10) ? '0' + d : d;
    var m = date.getMonth() + 1;
    var month = (m < 10) ? '0' + m : m;
    var yyyy = date.getFullYear();
    var yyyymmdd = yyyy.toString() + month.toString() + day.toString();
    document.write("<font face='Verdana'><font color='#000066'><font size=-1><b><u><a href='L:/main/Status/" + yyyymmdd + ".xls' target='_blank'>Click Here For Today's Status</a></u></b>");
    </script>


    Older documents are moved out of the 'Status' directory. For example, the document from March 15, 2004 would be
    L:/main/Status/2004/2004_03/20040415.xls. Can I capture three input date fields and then use them to create a new <a href> tag? For example:

    <a href='L:/main/Status/" + yyyy + "/" + yyyy + "_" + mm + "/" + yyyymmdd + ".xls' target='_blank'></a>

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Try this:
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <
    html>
    <
    head>
    <
    title>Untitled Document</title>
    <
    meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <
    meta http-equiv="Content-Style-Type" content="text/css">
    <
    meta http-equiv="Content-Script-Type" content="text/javascript">
    <
    script language="JavaScript" type="text/JavaScript">
    function 
    stat(){
    var 
    date = new Date();
    var 
    date.getDate();
    var 
    day = (10) ? '0' d;
    var 
    date.getMonth() + 1;
    var 
    month = (10) ? '0' m;
    var 
    yyyy date.getFullYear();
    var 
    yyyymmdd yyyy.toString() + month.toString() + day.toString();
    window.open('L:/main/Status/'+yyyymmdd+'.xls','newp')
    }
    function 
    newstat(){
    var 
    yyyy document.getElementById('txy').getAttribute('value');
    var 
    mm document.getElementById('txm').getAttribute('value');
    var 
    dd document.getElementById('txd').getAttribute('value');
    window.open('L:/main/Status/'+yyyy+'/'+yyyy+'_'+mm+'/'+yyyy+mm+dd+'.xls','newp')
    }
    </script>
    </head>
    <body>
    <font face="Verdana" color="#000066" font size="-1"><b><u><a href="#" onclick="stat();return false">Click 
    Here For Today's Status</a></u></b></font> <br>
    <br>
    Enter new date:<br>
    yyyy
    <input type="text" id="txy"><br>
    mm
    <input type="text" id="txm"><br>
    dd
    <input type="text" id="txd">
    <br>
    <br>
    <font face="Verdana" color="#000066" font size="-1"><b><u><a href="#" onclick="newstat();return false">Click 
    Here For The New Date's Status</a></u></b></font> 
    </body>
    </html> 
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That did it. Thanks a lot!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •