Unusual javascript question on setting a field via code executed from object

Discussion in 'Javascript' started by Colin Colin, Apr 2, 2004.

  1. Colin Colin

    Colin Colin Guest

    I downloaded a calendar.asp file that someone named Jacob "WickedPisser"
    Gilley made. It's a few years old but It works fine and it's what I was
    looking for without getting into ActiveX objects. But I am having
    trouble with something that I beleive it's because of my lack of
    JavaScript knowledge.

    In the initilizing code, he has:
    ' Add event code for when a day is clicked on. Notice
    ' that when run inside your browser, "$date" is replaced
    ' by the date you click on.
    MyCalendar.OnDayClick = "javascript:alert('You clicked on this date:
    $date')"

    So when I run the page, when I click on a day I get an alert box saying
    'You clicked on this date: 3/26/2004', but with the date being the day
    that I clicked on. So I wanted to change the javascript to set the
    field for the day I clicked on, so I tried several things:

    MyCalendar.OnDayClick =
    "javascript:document.frmAddVisitCal.AP_DATE.value = $date"
    MyCalendar.OnDayClick =
    "javascript:document.frmAddVisitCal[AP_DATE].value = $date"
    MyCalendar.OnDayClick =
    "javascript:window.document.frmAddVisitCal.AP_DATE.value = $date"
    MyCalendar.OnDayClick =
    "javascript:window.document.frmAddVisitCal[AP_DATE].value = $date"
    MyCalendar.OnDayClick =
    "javascript:window.opener.document.frmAddVisitCal.AP_DATE.value = $date"
    MyCalendar.OnDayClick =
    "javascript:window.opener.document.frmAddVisitCal[AP_DATE].value =
    $date"

    But none of them worked, I get 'Is Null or NOt an object'

    So why can't I reference my field object? the form is correct and the
    field name is correct.




    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Colin Colin, Apr 2, 2004
    #1
    1. Advertising

  2. Re: Unusual javascript question on setting a field via code executedfrom object

    Colin Colin wrote:

    > I downloaded a calendar.asp file that someone named Jacob "WickedPisser"
    > Gilley made. It's a few years old but It works fine and it's what I was
    > looking for without getting into ActiveX objects. But I am having
    > trouble with something that I beleive it's because of my lack of
    > JavaScript knowledge.
    >
    > In the initilizing code, he has:
    > ' Add event code for when a day is clicked on. Notice
    > ' that when run inside your browser, "$date" is replaced
    > ' by the date you click on.
    > MyCalendar.OnDayClick = "javascript:alert('You clicked on this date:
    > $date')"
    >
    > So when I run the page, when I click on a day I get an alert box saying
    > 'You clicked on this date: 3/26/2004', but with the date being the day
    > that I clicked on. So I wanted to change the javascript to set the
    > field for the day I clicked on, so I tried several things:
    >
    > MyCalendar.OnDayClick =
    > "javascript:document.frmAddVisitCal.AP_DATE.value = $date"
    > MyCalendar.OnDayClick =
    > "javascript:document.frmAddVisitCal[AP_DATE].value = $date"
    > MyCalendar.OnDayClick =
    > "javascript:window.document.frmAddVisitCal.AP_DATE.value = $date"
    > MyCalendar.OnDayClick =
    > "javascript:window.document.frmAddVisitCal[AP_DATE].value = $date"
    > MyCalendar.OnDayClick =
    > "javascript:window.opener.document.frmAddVisitCal.AP_DATE.value = $date"
    > MyCalendar.OnDayClick =
    > "javascript:window.opener.document.frmAddVisitCal[AP_DATE].value =
    > $date"
    >
    > But none of them worked, I get 'Is Null or NOt an object'
    >
    > So why can't I reference my field object? the form is correct and the
    > field name is correct.
    >


    You need to put quotes around IDs. I am assuming you have a form with
    the ID frmAddVisitCal, and an input called "AP_DATE".

    To get the AP_DATE input element, you would write:

    document.getElementById("AP_DATE");

    But, you are putting that Javascript in ASP code (Not supported on this
    group). You will need to write a string like this:

    "document.getElementById(\"AP_DATE\");"

    Of course, that assumes that you escape quotes with a backslash. If I
    remember correctly, VBScript with ASP uses a different syntax, but I
    havent done that in years.

    Next problem... using the javascript: method. See the FAQ:
    http://www.jibbering.com/faq/#FAQ4_24

    You should probably use a different method... but without seeing the
    code you are actually working with, I cannot suggest any more.

    Brian
     
    Brian Genisio, Apr 2, 2004
    #2
    1. Advertising

  3. Colin Colin

    Colin Colin Guest

    You were a great help, thanks.



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Colin Colin, Apr 5, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Garance A Drosihn

    Exit status on cmd executed via popen()

    Garance A Drosihn, Nov 24, 2003, in forum: Ruby
    Replies:
    3
    Views:
    853
    Gennady
    Nov 25, 2003
  2. Unusual javascript code

    , Jun 23, 2005, in forum: Javascript
    Replies:
    1
    Views:
    82
  3. Sound
    Replies:
    2
    Views:
    465
    Randy Webb
    Sep 28, 2006
  4. jr
    Replies:
    3
    Views:
    448
  5. Íéêüëáïò Êïýñáò
    Replies:
    1
    Views:
    124
    Íéêüëáïò Êïýñáò
    Jun 4, 2013
Loading...

Share This Page