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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Postback Dynamicly Changed Listbox Woes

Status
Not open for further replies.

bernie321

Programmer
Jan 7, 2004
477
GB
Hi

We are using the below JavaScript code to postback all rows in a listbox that has been altered using javascript, but it is driving me up the wall as it just errors all the time:

//Javascript post back function
function SaveAddedItems(ctrlSource, ctrlTarget)
{
var Source = eval('document.forms[0].' + ctrlSource);
var Target = eval('document.forms[0].' + ctrlTarget);
for (i = 0; i < Source.options.length; i++)
{
var current = Source.options;
added += ";" + current.value; //ERROR HERE: Microsoft JScript runtime error: Object expected
}
}

Attibute added to VB .NET Page on form load:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


cmdStep2.Attributes.Add("onclick", "SaveAddedItems('usrMain__ctl0_chkMetaList', 'usrMain__ctl0_txthiddenControl');")

End Sub

I know this is javascript but I thought this may be a better place to post as it is an ASP .NET workaround.

Any advice would be much appreciated.

Thanks
B
 
The error is because the relevant object isn't being found. The fact that you are using ASP.NET is irrelevant and therefore you should ask in the javascript forum and provide them with the client side code for the entire page and any related javascript files.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top