having javascript call a specific value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • printline
    New Member
    • Jul 2006
    • 89

    having javascript call a specific value

    Hello

    I'm a bit new to javascript. Hope somebody can help me

    I have a table with 7 colums and 5 rows. 1 row and 1 column has headlines. In the table i have cells with different numbers in them. When i mark a headline row and a headline column a specific celle is highlighted.

    What i need is a javascript that shows the user, in text, the value of the cell he has highlighted. Ex: "you have selected column 3, row 4, which has the value xxx".

    Perhaps this can be doe be giving each cell a unique id, or something....

    Please help......

    Thank you!
  • iam_clint
    Recognized Expert Top Contributor
    • Jul 2006
    • 1207

    #2
    you can probably piece this togethor by using my example code at the top of the javascript forum for reading cells like excel.

    Comment

    • printline
      New Member
      • Jul 2006
      • 89

      #3
      To some extend useful, yes...... Could you perhaps tell me how to make the content in the cells work like a link, so that when you click it, it shows the value in the text field.....?

      Comment

      • iam_clint
        Recognized Expert Top Contributor
        • Jul 2006
        • 1207

        #4
        you would add an onclick to display it
        [CODE=javascript]
        <div id="example"></div>
        <table>
        <tr><td onclick="docume nt.getElementBy Id('example').i nnerHTML = this.innerHTML" style="cursor: pointer;"></td></tr>
        </table>
        [/CODE]

        Comment

        • printline
          New Member
          • Jul 2006
          • 89

          #5
          Works great, thank you very much!

          One little extra thing though you perhaps could help me with.

          If i would like there to be a text in front of the content, when clicking it, how would i do that?

          Ex. The cell contains the number 100. When clicked, the number appears somewhere else and in front of it, it says, "You have selected 100"

          Comment

          • iam_clint
            Recognized Expert Top Contributor
            • Jul 2006
            • 1207

            #6
            I guess I really don't see what you mean?

            Say that again in a different way.

            Comment

            • printline
              New Member
              • Jul 2006
              • 89

              #7
              Okay, let me try explaining it again, a bit more in details.

              The first script you gave me, you put in a div tag, where the content of the cell should be displayed, when clicking the cell.

              in that div tag, i would like there to be some additional text, but only to appear when clicking the contant of the cell.

              Let's say the content in the cell says 100 $. When clicking the cell, the div tag should read: "You have selected 100 $".

              The "You have selected" part is not visible unless you click the contant of the cell.

              Hope this explains it better.....

              Comment

              • iam_clint
                Recognized Expert Top Contributor
                • Jul 2006
                • 1207

                #8
                [CODE=javascript]
                <div id="example"></div>
                <table>
                <tr><td onclick="docume nt.getElementBy Id('example').i nnerHTML = 'You have selected ' + this.innerHTML" style="cursor: pointer;"></td></tr>
                </table>
                [/CODE]

                this should work for ya.

                Comment

                • printline
                  New Member
                  • Jul 2006
                  • 89

                  #9
                  Brilliant!!!

                  Thanks very much....

                  Comment

                  Working...