Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

position of div using show-hide problem

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

I have a 2 divs, on a change event i show one and hide the other.
The problem that I have is, the two div's(which contain select boxes) appear in different positions.
i.e the the div whch is visible by default, when i hide it and show the other one, the 2nd one comes on a line below the first one.
I want the second one to appear in the same place as the first one.
I am pasting the part of code here please help.

<tr>
<td class='RMDataLeftAlignedBold'>State*</td>
<td class='RMDataLeftAlignedBold'>

<div id="selectnone">
<select name="fldState1">
<option value=" ">Select State</option>
</select>
</div>
<div id="selectstate" style="hidden">
<select name="fldState">
<option value=" ">Select State</option>
<xsl:for-each select='//statrs/statelist'>
<option value="{@idstate}">
<xsl:value-of select="@namstate"/>
</option>
</xsl:for-each>
</select>
</div>
</td>
<script language="JavaScript">
var ctry_opt=document.frmRegSubAgent.fldCountry.value;
showhide(ctry_opt);
</script>
</tr>
 
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Verify the code in the given link. The key is to use style.display instead of hidden.

http://www.ckarthi.com/test.html
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it would be better to use style = "display: none;" (and then "display: block;" to show them) rather than style = "visibility: hidden;". The only problem is then that if BOTH of the elements are displayed or BOTH are not displayed, then it could affect the positioning of everything else. An alternative would be to use CSS absolute positioning to place the elements in the same position as each other, and then you would have the flexibility to use the "visibility" option, and the whole thing would be independent of any other element on the page. It would mean moving away from using tables though......
 
Nazneen Shaikh
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great one guys... it was spot on..thanks a lot
 
reply
    Bookmark Topic Watch Topic
  • New Topic