| View previous topic :: View next topic |
| Author |
Message |
yaymeq
Joined: 18 Mar 2008 Posts: 2
|
Posted: Tue Mar 18, 2008 1:17 am Post subject: show div with drop down list |
|
|
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 |
|
 |
|
|
rangana 250+ Club

Joined: 27 Feb 2008 Posts: 439 Location: Cebu City Philippines
|
Posted: Tue Mar 18, 2008 3:12 am Post subject: Re: show div with drop down list |
|
|
Hi there yaymeq,
We've met again, the code looks familiar isn't it? Lol.
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.
Hope it help  |
|
| Back to top |
|
 |
yaymeq
Joined: 18 Mar 2008 Posts: 2
|
Posted: Tue Mar 18, 2008 3:24 am Post subject: Re: show div with drop down list |
|
|
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.  |
|
| Back to top |
|
 |
|