Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Correct my syntax please!
Old 04-07-2009, 07:16 PM Correct my syntax please!
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
It is down to this...

Code:
 
        switch (document.getElementById(Title[Column]))
     {
      case "[object HTMLDivElement]":
       alert("[object HTMLDivElement]");
       document.getElementById(Title[Column]).innerHTML = DataString;
      break;
 
      case "[object HTMLInputElement]":
       alert("[object HTMLInputElement]");
       document.getElementById(Title[Column]).value = DataString;
      break;
      case "[object HTMLTextAreaElement]":
       alert("[object HTMLTextAreaElement]");
       document.getElementById(Title[Column]).innerHTML = DataString;
 
     break;
     }
I am fairly certain that my syntax in the case statements is wrong, if so, what should it be?
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!

Last edited by Sleeping Troll; 04-07-2009 at 07:30 PM..
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-07-2009, 10:56 PM Re: Correct my syntax please!
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
For one thing, instead of switching the getElementById directly, you should be switching each node's nodeName property. This is the only way I think that will return a standardized result.

The nodeName property is always a capitalized version of the HTML tag.

Other than that, your syntax is correct. The case statement in JavaScript is exactly like PHP and most other C-family languages.

Code:
switch (document.getElementById(Title[Column]).nodeName) {
     case "DIV":
     //do stuff
     break;
     //etc
}
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to Correct my syntax please!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.79088 seconds with 12 queries