By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,947 Members | 1,505 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,947 IT Pros & Developers. It's quick & easy.

Dynamically declare objects in javascript

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.