Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


show div with drop down list



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> JavaScript Forum
View previous topic :: View next topic  
Author Message
yaymeq



Joined: 18 Mar 2008
Posts: 2

PostPosted: Tue Mar 18, 2008 1:17 am    Post subject: show div with drop down list Reply with quote

I've got a form and it has a drop down list like so :
Code:
<select name="Hearaboutus"  onchange="change()" id="choose">
         <option value="pleasechoose">Please choose</option>
         <option value="Friend">Friend</option>
         <option value="Real estate agent"> Real estate agent</option>
         <option value="Search engine"> Search engine</option>
         <option value="Sign"> Sign</option>
         <option value="Flyer"> Flyer</option>
         <option value="Business card"> Business card</option>
         <option value="Direct mail"> Direct mail</option>
         <option value="Other"> Other </option></select>


If they select "other" I want:
Code:
   <tr valign="top" id="ifother">
      <td align="right" >If other please explain.</td>
      <td align="left"><input type="text" name="whoisother" value="" maxlength="100" size="30"></td>
   </tr>

to appear. I've got some Idea of how to do this ... for example:
Code:
<script type="text/javascript">

window.onload = function()
{                                            //line51
document.getElementById("change").style.display='none';
}

function change()
{
   switch (document.getElementById("choose").value)
   {
      case "Friend":
     document.getElementById("ifother").style.display='none'
      break;
      case "Real estate agent":
     document.getElementById("ifother").style.display='none'
      break;
      case "Sign":
     document.getElementById("ifother").style.display='none'
      break;
      case "Other":
     document.getElementById("ifother").style.display=''
      break;
   }
}
obviously with the rest of the cases as well, but it's not working. The problem is that when I do this piece of code by itself it says an object is required on line 51 which I've marked. I don't understand it.
Back to top
View user's profile Send private message Visit poster's website
rangana
250+ Club


Joined: 27 Feb 2008
Posts: 259
Location: Cebu City Philippines

PostPosted: Tue Mar 18, 2008 3:12 am    Post subject: Re: show div with drop down list Reply with quote

Hi there yaymeq,
We've met again, the code looks familiar isn't it? Lol. Smile

Anyway that error is brought by:
Code:

window.onload = function()
{
document.getElementById("change").style.display='none';
}


Note that you don't have an element that has an id change in your page. Wink

Hope it help Smile
Back to top
View user's profile Send private message Yahoo Messenger
yaymeq



Joined: 18 Mar 2008
Posts: 2

PostPosted: Tue Mar 18, 2008 3:24 am    Post subject: Re: show div with drop down list Reply with quote

Ah and see I went elsewhere because I didn't want to be a bother always asking the same things. Well, I actually got it to work on my own! I don't remember what I did ... I tried many different combinations and the same one that didn't work the first time worked the second so who knows ... Anyway, thanks for all the help. Smile
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> JavaScript Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap