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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    518
    Thanks
    25
    Thanked 0 Times in 0 Posts

    need help with ajax and onload for dhtml calendar

    Hi all,

    im using a free dhtml calendar (from epoch) and have had no problems up to now.

    the issue is that you initiate the calendar's relationship with a field in an onload event. such as:
    [script]
    <script type="text/javascript">
    var reqdate_cal, plant_off_date_cal, plant_off_date_cal, itemreqdate_cal; //calendar popups!
    window.onload = function () {
    reqdate_cal = new Epoch('epoch_popup','popup',document.getElementById('reqdate'));
    plant_off_date_cal = new Epoch('epoch_popup','popup',document.getElementById('plant_off_date'));
    plant_on_date_cal = new Epoch('epoch_popup','popup',document.getElementById('plant_on_date'));
    itemreqdate_cal = new Epoch('epoch_popup','popup',document.getElementById('itemreqdate'));
    }
    </script>
    [/script]
    basically this sets up so that if you click on say, 'itemreqdate' field a new object is created.

    due to the fact that i am using ajax to create more fields that need this relationship i need a way to get new lines into the onload.

    the code i have on the bottom of the returned ajax is:

    <script>
    var oldWindowOnload = window.onload;
    window.onload = function(e) {
    if(oldWindowOnload) oldWindowOnload(e);
    <php loops thru all fields>
    echo "var itemreqdate{$row['id']}_cal = new Epoch('epoch_popup','popup',document.getElementById('itemreqdate{$row['id']}'));";
    <end of php looping>
    }
    <script>
    the 'var oldWindowOnload = window.onload' section just stops the first set of onload events being overwritten by the new set.

    any ideas? im stumped...
    "They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    If you are setting that new window.onload code in the innerHTML of the page, it is not going to run. PLUS there is no onload event after the page has run.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    518
    Thanks
    25
    Thanked 0 Times in 0 Posts
    yeah - i know... i just wanted to know if there was a way to do an onload any other way?
    "They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    518
    Thanks
    25
    Thanked 0 Times in 0 Posts
    i added them to an image's onload and that worked fine
    "They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson


  •  

    Posting Permissions

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