Ajax Talk - Asynchronous javascript and xml discussion board
 FAQ   Search    Usergroups      Register   Profile   Check your messages   Log in 
Signup now to enjoy a range of free membership advantages !!
Ajax Talk - Moderators Wanted
Show / Hide Text

 
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help
View previous topic :: View next topic  
Author Message
mme
New one
New one


Joined: 22 Apr 2008
Posts: 1

PostPosted: Tue Apr 22, 2008 4:07 am    Post subject: Show / Hide Text Reply with quote

Hi

I am trying to make it when using grouped radio buttons the user either presses yes or no.
When Yes is pressed it shows the content in div id "dn2" and when No is pressed it hides div id "dn2" and shows "dn" instead. But when the page is loaded neither div id "dn" or "dn2" are to be shown.

Code:
<body>
<script type="text/javascript">
if( document.getElementById ) {
getElemById = function( id ) {
return document.getElementById( id );
}
} else if( document.all ) {
getElemById = function( id ) {
return document.all[ id ];
}
} else if( document.layers ) {
getElemById = function( id ) {
return document.layers[ id ];
}
}
function showhide( el, id) {
if ( el && el.style ) {
getElemById( id ).style.display = (el.checked)? 'none' : '';
}
}
</script>
<label>
  <input type="radio" name="q1" value="radio" id="q1_0" onclick="showhide(this, 'dn2');" />
Yes</label>
   
  <label>
  <input type="radio" name="q1" value="radio" id="q1_1" onclick="showhide(this, 'dn');" />
No</label>
  <br>
 
  <div id="dn" class="noshow">Text 1</div>
  <div id="dn2" class="noshow">Text 2</div>
</body>


Thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
 Advertisements
 XML & Copyright Notice 
    


Powered by phpBB © 2001, 2005 phpBB Group

What is according to Wikipedia: Ajax Web2.0 XML E4X


Link to our site:

  


del.icio.us digg spurl wists simpy newsvine blinklist furl blogmarks yahoo! myweb smarking ma.gnolia segnalo reddit fark technorati cosmos


Normal Bookmark


Partner Button Links:
Codecrunch.com: Webmaster Tutorials    One Ajax


Partner Text Links:
quomon | web20log | ajaxmatters | tableless | 456bereastreet | music charts | gift ideas | competitions | free xbox 360 | link trade ?


Credits:
it consultancy & project management lead generation zoekmachine optimalisatie steal these buttons seo expert