J
Joey
I am attempting to hook the onChange event for a dropdown list with
javascript so that I can do some stuff and then initiate a postback
with my code. I have not yet learned about how to do postbacks with
javascript code...I have always relied on the dropdown list's
AutoPostBack=true property to do it for me.
I am basically trying to intercept the process and put my own code
in...I want to handle the onchange event clientside and then continue
on with the postback after (from my code). To do this, I changed the
dropdown list's AutoPostBack property to false, added an onChange
attribute to it, and then linked in the code below. And now, when I
select something, the alert box shows, but the page doesn't post back.
After I acknowledge the alert box, it just throws an "object expected"
javascript error.
code:
function CheckAndThenPostBack()
{
switch(document.all['ddlMyList'][document.all['ddlMyList'].selectedIndex].value)
{
case '1':
window.alert('1');
break;
case '2':
window.alert('2');
break;
case '3':
window.alert('3');
break;
default:
break;
}
__doPostBack('ddlMyList','')
}
I copied the "__doPostBack('ddlMyList','')" line straight from the page
source, after it had been displayed earlier, when the dropdown list had
AutoPostBack=true.
What am I doing wrong?
javascript so that I can do some stuff and then initiate a postback
with my code. I have not yet learned about how to do postbacks with
javascript code...I have always relied on the dropdown list's
AutoPostBack=true property to do it for me.
I am basically trying to intercept the process and put my own code
in...I want to handle the onchange event clientside and then continue
on with the postback after (from my code). To do this, I changed the
dropdown list's AutoPostBack property to false, added an onChange
attribute to it, and then linked in the code below. And now, when I
select something, the alert box shows, but the page doesn't post back.
After I acknowledge the alert box, it just throws an "object expected"
javascript error.
code:
function CheckAndThenPostBack()
{
switch(document.all['ddlMyList'][document.all['ddlMyList'].selectedIndex].value)
{
case '1':
window.alert('1');
break;
case '2':
window.alert('2');
break;
case '3':
window.alert('3');
break;
default:
break;
}
__doPostBack('ddlMyList','')
}
I copied the "__doPostBack('ddlMyList','')" line straight from the page
source, after it had been displayed earlier, when the dropdown list had
AutoPostBack=true.
What am I doing wrong?