Link to home
Start Free TrialLog in
Avatar of Lorna70
Lorna70

asked on

Using popup window from control in DetailsView - problems assigning value to control

Hi I'm calling a javascript Datepicker function from a TextBox control in DetailsView and after selecting a date I have to assign the date value to my TextBox control.  My controls are named as follows:
Form with ID="form1"
Details view with ID="dvRoute"
TextBox with ID="txtRouteDate"

My code is:
var ctl = "dvRoute_txtRouteDate";
window.opener.document.form1[ctl].value = dateValue;

This is not working - is there another way to do this or is my syntax wrong?

ASKER CERTIFIED SOLUTION
Avatar of gamarrojgq
gamarrojgq

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lorna70
Lorna70

ASKER

Thanks tried that and still get a similar errorL
Microsoft JScript runtime error: 'window.opener.document.getElementById(...)' is null or not an object

I think my problem is not knowing how to reference a TextBox which is inside a DetailsView which is inside a Form.  I tried:

ctl = "form1_dvRoute_txtRouteDate";
What is the correct syntax for doing this?  Should I be using [] instead of _??
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lorna70

ASKER

OK - my text box is "dvRoute$txtRouteDate" in the source but it still doesn't work.  Should I add the form name to the ctl var before I run:

var ctl = "dvRoute$txtRouteDate"
window.opener.document.getElementById(ctl).value = dateValue;

??
Avatar of Lorna70

ASKER

It worked!

For anyone else struggling with this - I went back to using:

var ctl = "dvRoute$txtRouteDate"
window.opener.document.form1[ctl].value = dateValue;