473,320 Members | 1,870 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,320 software developers and data experts.

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(document.forms['formname'].elements['fieldname']);
cal6.year_scroll = 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 6391
How about using an array:

var cal = new Array();

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

jo*******@eircom.net (Secondpost) wrote in message news:<25**************************@posting.google. 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(document.forms['formname'].elements['fieldname']);
cal6.year_scroll = 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="Javascript">
var calnew = new Array();

function myfun(index){
calnew[index] = new calendar1(document.forms['myform'].elements['txtTaskStartDate1']);
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*********@cliffhanger.com (Mike Jones) wrote in message news:<8c**************************@posting.google. com>...
How about using an array:

var cal = new Array();

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

jo*******@eircom.net (Secondpost) wrote in message news:<25**************************@posting.google. 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(document.forms['formname'].elements['fieldname']);
cal6.year_scroll = 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
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...
9
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
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...
39
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. ...
1
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,...
9
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 ...
5
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
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....
29
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 =...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.