Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Javascript to update control values 1

Status
Not open for further replies.

Casbah

Programmer
May 18, 2004
31
IE
Hi, I have an asp.net 2.0 form.
It is made up as follows
It has a master page
It has 2 custom controls.
In one of the custom controls I have a read only text box
I have a button here too that opens a popup calendar
I want to populate the text box with the value from the calendar... My javascript is as follows
function OpenCalendar(idname)
{
var popUp;
var MyArgs = new Array('A');


for (var i = 0; i < 20; ++i)
{
// alert(document.forms[0].elements.name.substr(0, idname.length))
}
//var newUrl= 'Calendar.aspx?selected=' + document.forms[0].elements[idname].value;
var newUrl = 'Calendar.aspx'
popUp = window.showModalDialog(newUrl, MyArgs, WinSettings);
if (popUp != null)
{if (popUp[0] !== 'CANCEL')
{
document.forms[0].elements[idname].value = popUp[0].toString();
}
}


However it never finds my textbox control to update.
the call to the javascript is
javascript:OpenCalendar('txtDateStart') for the textbox...
If i do a loop through all the document.forms[0].elements and print their name the name i get for this txtDateStart is: ctl00$ContentPlaceHolder1$EntertainmentAdminPanel1$txtDateStart

Am I doing sometihng wrong?
Do I have to pass this full name for it to work?
Thanks
 
Yes, you have to pass the full name through otherwise the javascript can't find the element. You can find the id that is rendered by using the ClientID property of the relevant control.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top