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
document.getElementById help please
Old 07-31-2007, 05:26 AM document.getElementById help please
Experienced Talker

Posts: 39
Trades: 0
hello

i have a problem, the following code works okay.

Code:
function showhidetextBox()
{
selectedValue = document.getElementById("Sport_Type").value;
if (selectedValue == "Multisports Tour")
document.getElementById("Which_Multitour").style.display = "";
else
document.getElementById("Which_Multitour").style.display = "none";
 }
but if i try and add an additional document.getElementById (like below) I get errors. Can anyone see why?

Code:
function showhidetextBox()
{
selectedValue = document.getElementById("Sport_Type").value;
if (selectedValue == "Multisports Tour")
document.getElementById("Which_Multitour").style.display = ""
document.getElementById("Which_Multitour").value = "Please Specify";
else
document.getElementById("Which_Multitour").style.display = "none";
 }
Thanks in advance!

Paul
69me is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-31-2007, 07:36 AM Re: document.getElementById help please
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
An if/else blocks works without delimiter, but in that case only the first line is taken in account.

Your error is that as you have 2 lines in the if() block, the else is considered as an orphan by the scripting engine.

Rewrite it like:
Code:
if (selectedValue == "Multisports Tour"){
  //You may prefer to set the display to "block", to ensure that it's visible.
  //Your syntax here means "fall back on the style specified inline", and might be a problem if you update your html
  document.getElementById("Which_Multitour").style.display = ""; 
  document.getElementById("Which_Multitour").value = "Please Specify";
}
else{
  document.getElementById("Which_Multitour").style.display = "none";
}
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 07-31-2007 at 07:38 AM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to document.getElementById help 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.60625 seconds with 12 queries