#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    51
    Rep Power
    12

    javascript - problem i think with getelementbyid


    it's me again...sorry for the constant questions...

    I have a webpage in which i call a pop up javascript calendar....i do this with the following code

    Code:
    <input type="button" onclick='popUpCalendar(this, app_form.date , "dd mmm yyyy",0,-200,1)' value="Change date" style="font-size:11px" />
    where app_form is the name of the form
    and date is a hidden text field in the form

    This has been working fine, but i have now added a navigation bar to the page. When i call the pop up calendar function i get an error saying that app_form is undefined. I think this is because the navigation bar also has a form, obviously with a different name. When i am calling the function now do i have to get the form and field by saying something like....

    Code:
    <script>var date_targ = document.getelementbyid('app_form.date');</script>
    	<input type="button" onclick='popUpCalendar(this, date_targ, "dd mmm yyyy",0,-200,1)' value="Change date" style="font-size:11px" />
    ...although this doesn't work....giving a "object does not support this property or method" error.

    can anyone help?

    also, can anyone recommend some good javascript tutorials/resources?

    Thanks

    Al.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    Newfoundland, Canada
    Posts
    102
    Rep Power
    12
    I believe getelementbyid only works in some versions of netscape. Instead, try this:
    if(document.layers){ // Internet Explorer
    date_targ = document.app_form.date;
    }
    if(document.all){ // Some Netscape
    date_targ = document.all.app_form.date;
    }
    if(document.getElementById){ // Other Netscape
    date_targ = document.getElementById("app_form").date;
    }


    Now, i'm not sure if this works, but its something to try and perhaps play around with.
    As for javascript resources, I started with good ol' web monkey:
    http://hotwired.lycos.com/webmonkey/...tutorial1.html
    And from there always do searches for whatever I'm trying to figure out! The internet is a wonderful reference. Anyone else have any good references?

IMN logo majestic logo threadwatch logo seochat tools logo