dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Start a Function via a Button ?

  1. #1
    Join Date
    Jan 2013
    Posts
    2

    Start a Function via a Button ?

    Hello & Thanks ,
    Newbie
    In the code below , I can't get the
    Functions GetTodaysPage and SaveTodaysPage
    to Run when I click on the Button(s) .
    Can someone show me what I am doing wrong ?

    Thanks...Vernon

  2. #2
    Join Date
    Jan 2013
    Posts
    2
    Oops , here's the code:
    <!DOCTYPE html>
    <!--
    __0.localstorage
    __0.localstorage-journal
    -->
    <html>
    <title>~~~localStorage-03.html</title>
    <head>
    <meta http-equiv="content-type" content="text/html;charset=UTF-8">
    <title></title>
    <script type="text/javascript">
    window.onload = function () {
    var TodaysDate = "01/29/13"
    var myKey = "myDiary_"+TodaysDate;
    alert("Hello , Today's Date is " + TodaysDate);
    }
    function GetTodaysPage () {
    document.getElementById("GetTodaysPage").onclick = function () {
    alert("Hello , from GetTodaysPage " + TodaysDate);
    TodaysPage = localStorage.getItem[myKey];
    } }
    function SaveTodaysPage () {
    document.getElementById("SaveTodaysPage").onclick = function () {
    alert("Hello , from SaveTodaysPage " + TodaysDate);
    localStorage.setItem[[myKey] , TodaysPage];
    } }
    </script>
    </head>
    <body>
    <div>
    <input type="button" value="GetToday'sPage" id="GetTodaysPage">
    <input type="button" value="SaveToday'sPage" id="SaveTodaysPage">
    </div>
    <div>
    <textarea id="TodaysPage" cols="80" rows="80"> </textarea>
    </div>
    </body>
    </html>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles