texaspete
asked on
Parsed variable is UNDEFINED
Hi there,
I've got some javascript that creates a button dynamically on the page. This button is used to open a calendar popup. Each time a new button is added a counter is appended to the element name to make it unique. e.g. escalation_date then escalation_date2, escalation_date3, escalation_date4 etc...
The following code creates the button fine but hard codes the second element name (document.add.escalation_d ate2 ) when calling openCalendar
var a = document.createElement('a' );
a.innerHTML = '<IMG src="/include/images/calen dar.gif" border=0 alt="Select Date">';
a.href = 'javascript:void(0);' ;
a.onclick = function () { return (openCalendar("add", document.add.escalation_da te2 )); };
td2.appendChild(a);
This works fine but I don't want to hard code the element name.
Here what i'm trying .......
var a = document.createElement('a' );
var element = ("document.add.escalation_ date" + (row_no))
a.innerHTML = '<IMG src="/include/images/calen dar.gif" border=0 alt="Select Date">';
a.href = 'javascript:void(0);' ;
a.onclick = function () { return (openCalendar("add", element )); };
td2.appendChild(a);
the var 'element' does hold the correct element name but when its passed to openCalendar (which creates the querystring) it is undefined.
here is ths openCalendar function
function openCalendar(iForm, sField)
{
var queryString;
queryString = '?Date=' + escape(sField.value);
queryString += '&FormName=' + escape(iForm);
queryString += '&DateFld=' + escape(sField.name);
var newWin = window.open("calendar.asp" + queryString, "calwin", "dependent=yes,directories =no,height =205,width =220,locat ion=no,men ubar=no,pe rsonalbar= no,resizab le=no,scro llbars=no, status=no, toolbar=no ,top=400,l eft=400");
return false;
}
This is the Querystring created: /calendar.asp?Date=undefin ed&FormNam e=add&Date Fld=undefi ned
Any help greately appriciated
Regards,
TP
I've got some javascript that creates a button dynamically on the page. This button is used to open a calendar popup. Each time a new button is added a counter is appended to the element name to make it unique. e.g. escalation_date then escalation_date2, escalation_date3, escalation_date4 etc...
The following code creates the button fine but hard codes the second element name (document.add.escalation_d
var a = document.createElement('a'
a.innerHTML = '<IMG src="/include/images/calen
a.href = 'javascript:void(0);' ;
a.onclick = function () { return (openCalendar("add", document.add.escalation_da
td2.appendChild(a);
This works fine but I don't want to hard code the element name.
Here what i'm trying .......
var a = document.createElement('a'
var element = ("document.add.escalation_
a.innerHTML = '<IMG src="/include/images/calen
a.href = 'javascript:void(0);' ;
a.onclick = function () { return (openCalendar("add", element )); };
td2.appendChild(a);
the var 'element' does hold the correct element name but when its passed to openCalendar (which creates the querystring) it is undefined.
here is ths openCalendar function
function openCalendar(iForm, sField)
{
var queryString;
queryString = '?Date=' + escape(sField.value);
queryString += '&FormName=' + escape(iForm);
queryString += '&DateFld=' + escape(sField.name);
var newWin = window.open("calendar.asp"
return false;
}
This is the Querystring created: /calendar.asp?Date=undefin
Any help greately appriciated
Regards,
TP
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Happy to help. Thanks!
mvan
mvan
ASKER
Have some points!