469,917 Members | 1,728 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

dynamic div

Hey,

What I'm trying to do is, based on a user selection from a drop down, dynamically show a div and it's contents. This is a short version of what I'm doing so code is missing.

I have the select with the onChange
Expand|Select|Wrap|Line Numbers
  1. <select id="program" tabindex="2" onChange="reveal(choice)" name="program">
  2.  

Then I have the div with the name
Expand|Select|Wrap|Line Numbers
  1. <div id="prerequisites_div"> </div>
  2.  
and then I have the function that handles the processing
Expand|Select|Wrap|Line Numbers
  1. function reveal(chosen)
  2. {
  3.  
  4.  
  5.     var n=1;
  6.     len = document.form1.program.length;
  7.     i = 0;
  8.     chosen = "none";
  9.  
  10.     for (i = 0; i < len; i++) 
  11.     {
  12.         if (document.form1.program[i].selected)
  13.         {
  14.  
  15.         chosen = document.form1.program[i].value
  16.  
  17.         } 
  18.     }
  19.     if (chosen == "BSN") 
  20.     {
  21.  
  22.     prerequisites_div.innerHTML = prerequisites_div.innerHTML +
  23.  
  24.     "<td align='middle' bgcolor='white' colspan='2'>....on and on to this" + n
  25.                  }
  26.                  else
  27.                  {
  28.                      return false;
  29.                  }
  30.  
  31. }
  32.  
Can someone help me see this through or steer in the right way to get this accomplished.
Dec 11 '07 #1
2 999
omerbutt
638 512MB
u havent explained u problem what are u trying to d where from the prerecquisites are you showing from a database or what are the hardcoded if you are rettrieving from a database are u using xmlhttpresponse object or what the way yu have told no one is going to answere don shy tp show up ur code buddy no ones gonna cheat it[:D]
Hey,

What I'm trying to do is, based on a user selection from a drop down, dynamically show a div and it's contents. This is a short version of what I'm doing so code is missing.

I have the select with the onChange
Expand|Select|Wrap|Line Numbers
  1. <select id="program" tabindex="2" onChange="reveal(choice)" name="program">
  2.  

Then I have the div with the name
Expand|Select|Wrap|Line Numbers
  1. <div id="prerequisites_div"> </div>
  2.  
and then I have the function that handles the processing
Expand|Select|Wrap|Line Numbers
  1. function reveal(chosen)
  2. {
  3.  
  4.  
  5.     var n=1;
  6.     len = document.form1.program.length;
  7.     i = 0;
  8.     chosen = "none";
  9.  
  10.     for (i = 0; i < len; i++) 
  11.     {
  12.         if (document.form1.program[i].selected)
  13.         {
  14.  
  15.         chosen = document.form1.program[i].value
  16.  
  17.         } 
  18.     }
  19.     if (chosen == "BSN") 
  20.     {
  21.  
  22.     prerequisites_div.innerHTML = prerequisites_div.innerHTML +
  23.  
  24.     "<td align='middle' bgcolor='white' colspan='2'>....on and on to this" + n
  25.                  }
  26.                  else
  27.                  {
  28.                      return false;
  29.                  }
  30.  
  31. }
  32.  
Can someone help me see this through or steer in the right way to get this accomplished.
Dec 12 '07 #2
acoder
16,027 Expert Mod 8TB
Use document.getElementById("prerequisites_div") to access the div element.

To hide it, set the style.display property to "none". You could do this inline, e.g.
[HTML]<div id="prerequisites_div" style="display:none">...</div>[/HTML]

To display the div, set the style.display property to "block".
Dec 12 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Guinness Mann | last post: by
6 posts views Thread by Materialised | last post: by
3 posts views Thread by Stephen Gennard | last post: by
reply views Thread by Pascal Costanza | last post: by
7 posts views Thread by Mike Livenspargar | last post: by
5 posts views Thread by bearophileHUGS | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.