473,386 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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.va lue = $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.frmAddVisit Cal[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!
Jul 23 '05 #1
1 1633
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.va lue = $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.frmAddVisit Cal[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
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

60
by: marss | last post by:
Maybe anyone know good free online JavaScript knowledge test? This not exactly a system for testing online required - it may be simply list of questions with variants of answers (I have to prepare...
2
Frinavale
by: Frinavale | last post by:
JavaScript in ASP.NET Using JavaScript in ASP.NET pages can make your application seem to work faster and prevent unnecessary calls to the server. JavaScript can be used to perform client-side...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.