• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

div not woking

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All!!!

can any one please help me out!!

actually the following div is not working i cant get why??



<select name="section" onChange="javascript:show('section');">
<option value="null"></option>
<option value="1">1</option>
</select>

<div id="section" style="display:none; width:270;" >

<table>
<tr>
<th>Section<span class="mandatory">(*)</span></th>
<th>Venue<span class="mandatory">(*)</span></th>
<th>Number of Trainees<span class="mandatory">(*)</span></th>
<th>Number of Invigilators <span class="mandatory">(*)</span></th>
<th>Number of Extra Invigilators at submission </th>
</tr>
<tr>
<td>
<input type="text" name="section" value="" size="15" disabled="disabled">
</td>

<td>
<input type="text" name="venue" value="" size="15">
</td>

<td>
<input type="text" name="noOfTrainees" value="" size="6">
</td>

<td>
<input type="text" name="noOfInvigils" value="" size="4">
</td>

<td>
<input type="text" name="noOfExtraInvigils" value="" size="4">
</td>
</tr>
</table>

</div>



//this is the js function
<script>

function show(tabName) {

if(document.getElementById(tabName).style.display == "none")
{
document.getElementById(tabName).style.display = "block";
}
else if(document.getElementById(tabName).style.display == "block")
{
document.getElementById(tabName).style.display = "none";
}
}

</script>
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by manik kant:
actually the following div is not working i cant get why?

What do you mean by "not working"? Does it burst into flames?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, please be sure to use UBB code tags when posting code to the forums. Unformatted code is extermely hard to read and many people that might be able to help you will just move along. Please read this for more information.

You can go back and change your post to add code tags by clicking the .
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to Javaranch.

I have tried your code in Mozilla firefox it works fine for me.
 
manik kant
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
its not the case dear but onchange it is not opened


Originally posted by Bear Bibeault:
What do you mean by "not working"? Does it burst into flames?

 
manik kant
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sir

thanks a lot for your pain but i am not getting then what can be the case with IE??

others are working fine but this is not

Originally posted by Muhammad Saifuddin:
Welcome to Javaranch.

I have tried your code in Mozilla firefox it works fine for me.

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I don't know what exactly you are trying to do. I guess you wish to show/hide the div based on the input selected in the select box(Please correct me if I'm wrong).

If the case as above, then you can simply use the visiblity parameter of style attribute of <div> as ---

Hide: document.getElementById(divId).style.visibility="hidden"
Show: document.getElementById(divId).style.visibility="visible"

Hope this helps you!!!
 
manik kant
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello and thanks alot for yopur help but the problem is that its not entering the if block.

it does enter the function but on changing the value from drop down div is not displayed.

i tried urs also but not working.
 
Mehul Wani
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, definitely it won't enter the if block because it does not return the value you are comparing in the if statement.

If you put an alert before if as shown you will easily come to know what is the value here's the code:

function show(tabName) {
//Add this line and you will come to know why it is not working
//alert(document.getElementById(tabName).style.display);
if(document.getElementById(tabName).style.display == "none")
{
document.getElementById(tabName).style.display = "block";
}
else if(document.getElementById(tabName).style.display == "block")
{
document.getElementById(tabName).style.display = "none";
}
}
 
Mehul Wani
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops!!! Sorry!! Just a correction in previous post's code
Uncomment the alert line

function show(tabName) {
//Add this line and you will come to know why it is not working
alert(document.getElementById(tabName).style.display);
if(document.getElementById(tabName).style.display == "none")
{
document.getElementById(tabName).style.display = "block";
}
else if(document.getElementById(tabName).style.display == "block")
{
document.getElementById(tabName).style.display = "none";
}
}
 
I can't take it! You are too smart for me! Here is the tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic