I’ve always managed to stay away from too much client side stuff so I’ve been struggling a bit with a few javascript things. Main one today was getting the selected value of drop down list. I wanted to do this as the value of this depended on whether to show a second drop down. Here’s the code to add the onchange event. This links together the DropDownList and the client side javascript code:
ddlCountry.Attributes.Add("onchange", "checkSelectedValue()")
And here’s the actual javascript code itself.
function checkSelectedValue()
{
if(document.Form1.ddlCountry[document.Form1.ddlCountry.selectedIndex].value < 0)
{ }
}
Thanks to Ray Booysen for helping me to solve that one!
I’m also having a bit of fun with the Custom Validator Control and a Check Box. I got it working fine for Internet Explorer, but alas in Firefox it doesn’t seem to work. Haven’t searched on Google for this one yet though so haven’t give up! I need a good book on ASP.NET and Javascript. Anyone recommend one?