473,800 Members | 2,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically declare objects in javascript

I need to use a calender object with a dynamic form i.e. when a new
row of fields is created using Javascript a calender button appears
aswell. The problem is if I need to declare the following code for the
calendar script to work:
var cal6 = new calendar1(docum ent.forms['formname'].elements['fieldname']);
cal6.year_scrol l = true;
cal6.time_comp = false;

where the # 6 will change as the user adds a new field (by clicking a
button).

My problem is that the code doesn't seem to execute during run-time.
If I add the code to the include file after the field is created it
still doesn't recognise that the calendar objects exists. Can anyone
help??
Jul 20 '05 #1
2 6410
How about using an array:

var cal = new Array();

function someFunction(in dex) {
cal[index] = new calendar1(etc.. .)
cal[index].year_scroll = true
}

jo*******@eirco m.net (Secondpost) wrote in message news:<25******* *************** ****@posting.go ogle.com>...
I need to use a calender object with a dynamic form i.e. when a new
row of fields is created using Javascript a calender button appears
aswell. The problem is if I need to declare the following code for the
calendar script to work:
var cal6 = new calendar1(docum ent.forms['formname'].elements['fieldname']);
cal6.year_scrol l = true;
cal6.time_comp = false;

where the # 6 will change as the user adds a new field (by clicking a
button).

My problem is that the code doesn't seem to execute during run-time.
If I add the code to the include file after the field is created it
still doesn't recognise that the calendar objects exists. Can anyone
help??

Jul 20 '05 #2
The script I've put into the head is :

<script language="Javas cript">
var calnew = new Array();

function myfun(index){
calnew[index] = new calendar1(docum ent.forms['myform'].elements['txtTaskStartDa te1']);
calnew[index].year_scroll = true;
calnew[index].time_comp = false;
};
</script>

Then I have a button on the page that onClick ="return
btnNew_onclick( 'People')"
where btnNew_onclick( 'People') calls a function in an include file (to
create the new fields) the last line of the function being
myfun(temp); where temp is the number of the object eg cal7. The field
is created along with the calender button with the correct hyperlink
but when this is clicked an error cal7 is undefined occurs.

What do you think I'm doing wrong??
Thanks.

in*********@cli ffhanger.com (Mike Jones) wrote in message news:<8c******* *************** ****@posting.go ogle.com>...
How about using an array:

var cal = new Array();

function someFunction(in dex) {
cal[index] = new calendar1(etc.. .)
cal[index].year_scroll = true
}

jo*******@eirco m.net (Secondpost) wrote in message news:<25******* *************** ****@posting.go ogle.com>...
I need to use a calender object with a dynamic form i.e. when a new
row of fields is created using Javascript a calender button appears
aswell. The problem is if I need to declare the following code for the
calendar script to work:
var cal6 = new calendar1(docum ent.forms['formname'].elements['fieldname']);
cal6.year_scrol l = true;
cal6.time_comp = false;

where the # 6 will change as the user adds a new field (by clicking a
button).

My problem is that the code doesn't seem to execute during run-time.
If I add the code to the include file after the field is created it
still doesn't recognise that the calendar objects exists. Can anyone
help??

Jul 20 '05 #3

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

Similar topics

10
9136
by: TheKeith | last post by:
I don't know much about javascript, so take it easy on me. Is there a way to dynamically change a CSS layers dimensions on the fly. Here is what I'm doing. I have a bunch of thumbnails that when clicked on, will open up the full view in a CSS layer, as opposed to a pop-up window let's say. I had this before, but with one layer for each image, and as you might imagine, the markup was way too bloated. So can I just change the css layers...
9
3732
by: pablo | last post by:
Dear NGers, I would like to change the alt-text with the changing of the image during a mouseover action. Can document.images.altView be changed dynamically? TIA, pablo
16
1831
by: sirsean | last post by:
Hi all. I'm trying to dynamically build menus and objects after my page loads. Data is stored in an XML file and is parsed at runtime into Javascript objects. At the moment, I'm working on creating menu items from these objects. The parsing works fine (using Sarissa), and Firefox builds the menu no problem. IE, however, does not. The functionality of the menu will be a single onclick event. It seems that Firefox allows me to set the...
39
6558
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. When it completes, it can call a success, or a failure function. The names of these success, or failure functions will differ, and I'd like to know how I can pass the name of a function to my tool, and how my tool can call the function, using that...
1
7269
by: Mohan | last post by:
Hi, In my application, I need to increase the 2-dimensional array size dynamically. Please let me know the procedure to declare a dynamic 2-dimensional array like Single dimensional array, ArrayList. Thanks, Mohan
9
3096
by: Patrick.O.Ige | last post by:
I have a code below and its a PIE & BAR CHART. The values now are all static but I want to be able to pull the values from a database. Can you guys give me some ideas to do this? Thanks Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Declare your object variables
5
5023
by: sfeher | last post by:
Hi All, I need to call a function(loaded with appendChild) for which I have the name as a string. .... var fnName = 'fn1'; var call = fnName + '('+ param +' )'; eval(call);
4
2180
by: somaskarthic | last post by:
Hi I posted query about dynamically generating php code. Sorry for the inconvenience . I didn't given you the php code. Its just javascript code which dynamically create rows on button click event. I'm not using javascript to get data from database. I'm fetching this using php code. I used square brackets to declare it as array. Hope you understand my problem. Or else , i explain here clearly be patience to read this. In my design i'm...
29
5452
by: Quarco | last post by:
This one is driving me nuts.... var tbl = document.createElement("table"); var tbody = document.createElement("tbody"); for(var i=0; i<10; i++) { var row = document.createElement("tr"); var curVAR = someCurrentValueOfArray;
0
9691
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10505
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10253
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9090
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7580
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6813
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.