Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Javascript Help

Options
  • 05-04-2007 5:01pm
    #1
    Closed Accounts Posts: 10


    Hi All,
    Need a bit of help. I hope this is the right place and that I have stuck to all the rules (there are quite a few). I;m scared that stupidity is a bannable offence.

    I have an .aspx page and the code is dynamically generated into two different table cells. THis particular time I need to hide one of the cells (when a - is displayed in one cell I need to hide a number that apears in the cell beside it) as it is causing confusion.

    THis is only a once off thing so I need to add a 'quick fix' if you like.

    The text is different in the cells each time the page is generated and the only thing I can think that can distinguish the cell apart from that is the style I have attatched using class="boMiddleCol1" and class="boRightCol1".

    I should add that javascript is NOT my strong point so please go easy on me....


    I found something that looks like itcould work.. but I don't know how to use it. It goes a little something like this
    <script language="javascript">

    var allPageTags = new Array(); function doSomethingWithClasses(theClass)
    { //Populate the array with all the page tags
    var allPageTags=document.getElementsByTagName("*");
    //Cycle through the tags using a for loop
    for (i=0; i<allPageTags.length; i++) {
    //Pick out the tags with our class name
    if (allPageTags.className==boMiddleCol1) {
    //Manipulate this in whatever way you want
    allPageTags.style.display='none'; } } }
    </script>


    but am finding it all a bit confusing...


    So I;m wondering how I get this code to pick up the class?
    Is there a better way to go about this?


    So if anyone can point me in the right direction for this that would be GREAT!


Comments

  • Closed Accounts Posts: 10 eventz_user


    Do I take it by the silnce that either this is going to be verry difficult or not really possible?

    Or is this the right place?

    :)


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    <script language="javascript">
    
    var allPageTags = new Array(); function doSomethingWithClasses(theClass) 
    {  //Populate the array with all the page tags  
    var allPageTags=document.getElementsByTagName("*"); 
     //Cycle through the tags using a for loop  
     for (i=0; i<allPageTags.length; i++) {  
     //Pick out the tags with our class name 
     if (allPageTags[i].className==[b]'boMiddleCol1'[/b]) {  
     //Manipulate this in whatever way you want  
     allPageTags[i].style.display='none';  }  } } 
    </script>
    

    I'd hazard a guess and say that you want to enclose the class name in quotes or populate a variable with it. I've enclosed it in quotes above, dunno if it will fix it but its a step in the right direction.


  • Closed Accounts Posts: 10 eventz_user


    Cool, makes sense :)
    Will test it now and see.
    Thanks Eveil Phil.


  • Users Awaiting Email Confirmation Posts: 351 ✭✭ron_darrell


    I don't really understand the question you have. Do you want an entire column of the table to vanish (if so then why not make the asp code make the column invisible) or individual cells in the column vanish (again can he asp code not handle this?)

    To hide individual cells then you really need to uniquely identify each cell and then run an onload script to examine the identifying cell and check if the need is there to hide the other cell or not (the identifier for each cell need to consistent so that identifying one identifies the other e.g. c1r1, c2r1 etc.)

    To hide an entire column then use the code you have provided.

    If you can illuminate the issue further I'll see if I can help. However I really think that the asp code should do this instead of javascript.

    -RD


Advertisement