none
Sending Text to a label onmouseover

    Question

  • Hi,
    I am attempting to have a label display a text description according to which button I rollover. I am having trouble updating the asp:label from within a JavaScript function or from plain html within the onmouseover of my images. The setup I would like to have is to call a function in the onmouseover event of the img like onmouseover="labeldisp(hello)" and have this labeldisp function write 'hello' to label1
    something like
    <script type="text/javascript" >
        var labeltxt;
        function labeldisp(labeltxt)
        {
        label1.Text = labeltxt.ToString() ;
         }
        </script>

    suggestions?

    <edit> I am using SharePoint Designer to edit the page and code


    thanks,
    Eric
    Wednesday, May 27, 2009 4:48 PM

Answers

  • Here was my solution...

    here in the image was the Onmouseover event that calls the function

    onmouseover="labeldisp('Text to display here'), this.src='images/imagePath';" onmouseout="labelclr(), this.src='images/imagePath';"


    Here are the functions called above

    <script type="text/javascript" >
        var labeltxt;
        function labeldisp(labeltxt)
        {
            document.getElementById('label2').innerHTML = labeltxt;
         }

        function labelclr()
        {
            document.getElementById('label2').innerHTML = "";
        }
     
        </script>
    • Marked as answer by esmullen Wednesday, May 27, 2009 6:28 PM
    Wednesday, May 27, 2009 6:28 PM

All replies



  • for getting insance of label use document.getElementById("labelID") or if that does not work then use the method as described in this link http://blogs.msdn.com/sharepointdesigner/archive/2007/06/13/using-javascript-to-manipulate-a-list-form-field.aspx
    Wednesday, May 27, 2009 4:54 PM
  • Here was my solution...

    here in the image was the Onmouseover event that calls the function

    onmouseover="labeldisp('Text to display here'), this.src='images/imagePath';" onmouseout="labelclr(), this.src='images/imagePath';"


    Here are the functions called above

    <script type="text/javascript" >
        var labeltxt;
        function labeldisp(labeltxt)
        {
            document.getElementById('label2').innerHTML = labeltxt;
         }

        function labelclr()
        {
            document.getElementById('label2').innerHTML = "";
        }
     
        </script>
    • Marked as answer by esmullen Wednesday, May 27, 2009 6:28 PM
    Wednesday, May 27, 2009 6:28 PM