A javascript if else statement...
ASP.NET
Thread Starter: mike55
Started: 05-13-2005 10:55
Replies: 1

Ireland .NET Developer Alliance :: Forums » Technologies » ASP.NET » A javascript if else statement...
« Previous Thread Next Thread »
   13 May 2005, 10:55
mike55 is not online. Last active: 01/06/2005 11:03:20 mike55

Top 10 Posts
Joined on 01-20-2005
Posts 23
A javascript if else statement...
Hi,

Have a piece of javascript that sets the maximum length of a multiline textbox to 500  characters.  I am trying to do a javascript if else statement based on a dropdown list in the same page, but I can't seem to reference the particular asp.net control, here is what I am doing:

var dropdown = document.getElementById(ddMessage);
if (dropdown.selectedindex == 0) {
var MaximumCharacters = "500";
} else{
var MaximumCharacters = "160";
}

The name of my dropdown is ddMessage.  The data stored in the dropdown is "Email", "SMS" and "Email & SMS".

Any suggestions appreciated.

Mike55      
  
   24 May 2005, 1:00
Dmitry is not online. Last active: 30/05/2005 16:48:58 Dmitry

Top 10 Posts
Joined on 03-24-2005
Posts 5
Re: A javascript if else statement...
Hi Mike, it should be okey as long as control with referenced Id exists.

document.getElementById('ddMessage'); // since ddMessage is a name rather than a var it should be taken into the quotes

Another thing is JScript is a case sensitive language, so you may want to change selectedindex to selectedIndex.

Cheers, Dmitry


Cheers, Dmitry
 
    
  Page 1 of 1 (2 items)
Ireland .NET Developer Alliance :: Forums » Technologies » ASP.NET » A javascript if else statement...

Powered by Community Server :: Forums