Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How can I assign the text on a <td> line as a variable?

    Hi,

    I am new on the HTML area and I would like to have some help from experienced users.

    I am building some html pages and I would like the cell content to change depending on other data in my html page.
    For example if the previous cell content is the same as the next one I would like the text content (Text Area) to be something different.

    I think I have figured out how to do the checking using Vbscript but I am not sure how to define the (Text Area) text to be what I want.

    <td colspan="1" class="sub_title">Text Area</td>

    Any help is greatly appreciated.

    Thank you

  • #2
    New Coder
    Join Date
    Jan 2012
    Posts
    97
    Thanks
    1
    Thanked 13 Times in 13 Posts
    Can you please provide a little more information? Is the previous cell content dynamic? Will it change every time the page loads or when the user clicks something?

    Either way this can be accomplished via JavaScript.

    If you know what the value will be when the page loads you can use:

    Code:
    <script type="text/javascript">
    window.onload=function(){
    
    var cellToCheckAgaints = document.getElementById("idOfCell").innerHTML;
            
    if (cellToCheckAgaints == 'some value')
    {
    document.getElementById("cellToChange").innerHTML = "change the text";
    }
            
    };
    </script>
    Similarly, if you are going to change the text when a button is clicked or something:

    Code:
    <script type="text/javascript">
    function buttonClicked(){
    
    var cellToCheckAgaints = document.getElementById("idOfCell").innerHTML;
            
    if (cellToCheckAgaints == 'some value')
    {
    document.getElementById("cellToChange").innerHTML = "change the text";
    }
            
    };


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •