HTML Help Forum Index HTML Help
Please Search for the answer to your question before asking it! Thanks.
 

hidding a table by radio button
Post a Reply to this Topic Ask a New Question
Click here to go to the original topic
       HTML Help Forum Index -> Javascript
View previous topic :: View next topic  
Author Message
one_more



Joined: 04 Jul 2005
Posts: 3

Posted: Mon Jul 04, 2005 11:03 pm     hidding a table by radio button  

hi :-)
I'm a new member, but not new here...
1st- thanks for your help till now.

my question is-
i want to hide and show a table by a radio button checking.
if i press radio 1- table is hidden, pressing radio 2 showing it.

my JavaScript is-
--
for (i=0;i<document[getNetuiTagName("myForm",this)].length;i++)
{
if (document[getNetuiTagName("myForm",this)].table[i].title=="roles");
document[getNetuiTagName("myForm",this)].table[i].style.display="none";
}
--
and i'm getting a "bug"- saying that:
document[getNetuiTagName("myForm",this)].table is not an object or null.

btw- all my tables have the attribute "title".

thanks for any help!
degsy



Joined: 23 Feb 2005
Posts: 2440
Location: North East, UK

Posted: Tue Jul 05, 2005 9:03 am      

Is it only one table that you want to change?
Why not use the table name or ID?
degsy



Joined: 23 Feb 2005
Posts: 2440
Location: North East, UK

Posted: Tue Jul 05, 2005 9:28 am      

Here is a script
Code:
<script>
function show(state){
tag = document.getElementsByTagName("table");

   for(i=0; i<document.form1.RadioGroup1.length; i++){
      if(document.form1.RadioGroup1[i].checked == true){
         for(x=0; x<tag.length; x++){
            if(tag[x].title == "roles"){
               tag[x].style.display = state
            }
         }
      }
   }
}
</script>
<form name="form1" id="form1" method="post" action="">
  <p>
    <label>
    <input type="radio" name="RadioGroup1" value="Hide" onclick="show('none')" />
    Hide</label>
    <br />
    <label>
    <input type="radio" name="RadioGroup1" value="Show" onclick="show('block')" />
    Show</label>
    <br />
  </p>
</form>
<table width="100" border="1" cellspacing="0" cellpadding="2" title="roles">
  <tr>
    <th scope="row">&nbsp;</th>
    <td>&nbsp;</td>
  </tr>
</table>


It looks overcomplicated because is it setup to be expanded to cover different elements and states.
one_more



Joined: 04 Jul 2005
Posts: 3

Posted: Wed Jul 06, 2005 11:39 pm     thanks  

first of all- thank u sooo much!
it really helped me- but not as i expected.
your help was here:
i'm using netui:html.
i wrote:
document[getNetuiTagName("myForm",this)].getElementById("table1").style.display="";
the problem was- i had to ommit the form.
simply like this:
document.getElementById("table1").style.display="";

thanks again!
have a nice day.
 
 
DARFUR
HOSTING / DESIGN
MAKE MONEY

       HTML Help Forum Index -> Javascript
Page 1 of 1


Powered by phpBB Search Engine Indexer
Powered by phpBB 2.0.19 © 2001, 2002 phpBB Group