8 Replies Latest reply on Mar 19, 2007 1:48 PM by insuractive

    text area value change

    craig_mac Level 1
      i have a text area with 5 text links underneath

      the text area value is not set, but what i need is if i click text link 1, then i need to update the value of the textarea with a value of a column in my table called message1 where userid = session.user

      how can i do this any ideas?
        • 1. Re: text area value change
          Dan Bracuk Level 5
          Do these links bring the user to bookmarks or other pages?
          • 2. Re: text area value change
            craig_mac Level 1
            ok i nearly have it working with the code below, but all i need to do now is when a single click it holds the value in the text area

            1. on mouse over = change text of text area to alt

            2. on mouse out clear the text area.

            3. on click display and hold the value of alt

            i have this code but it will not hold the value on click, because the the mouse out, how could i change this

            <a href="##" alt="#GetUser.MessageOne#" alt2="" onMouseOver="changeText(this.alt)" onMouseOut="changeText(this.alt2)" onClick="changeText(this.alt)">#GetUser.Title1#</a>
            • 3. text area value change
              insuractive Level 3
              How about:

              <a href="##" onClick="document.myFormName.myTextArea.value = '#GetUser.MessageOne#'">#GetUser.Title1#</a>

              Remember to change myFormName and myTextArea to their respective form and textarea element names.
              • 4. Re: text area value change
                craig_mac Level 1
                ok yes that would work but i also want to mouse over so it shows a preview
                • 5. Re: text area value change
                  insuractive Level 3
                  In that case, just add the same code to the onMouseOver, and have it set the text area to blank on the onMouseOut:

                  <a href="##" onClick="document.myFormName.myTextArea.value = '#GetUser.MessageOne#'" onMouseOver="document.myFormName.myTextArea.value = '#GetUser.MessageOne#'" onMouseOut="document.myFormName.myTextArea.value = ''">#GetUser.Title1#</a>
                  • 6. Re: text area value change
                    craig_mac Level 1
                    ok yes thats what i have before but if you click to slect the value then move the mouse out, it emptys the content

                    what i need is

                    1. if a mouse hovers over show a preview
                    2. if a mouse moves off the hover over clear the content.
                    3. onclick needs to display the value but then the problem comes when the mouse is moved off it clears the content
                    if onclick i need the value to be held when the mouse is noved off.

                    hope you can understand this
                    • 7. Re: text area value change
                      Level 7
                      craiglaw98 wrote:
                      > ok yes thats what i have before but if you click to slect the value then move
                      > the mouse out, it emptys the content
                      >
                      > what i need is
                      >
                      > 1. if a mouse hovers over show a preview
                      > 2. if a mouse moves off the hover over clear the content.
                      > 3. onclick needs to display the value but then the problem comes when the
                      > mouse is moved off it clears the content
                      > if onclick i need the value to be held when the mouse is noved off.
                      >
                      > hope you can understand this
                      >

                      yes, the onmouseout event will fire every time after you move the mouse
                      away from the links, even after you have clicked on it. you could write
                      a js function that will set some var to true if a link has been clicked
                      on, then another function for the onmouseout event that will execute
                      only if the var is still false (a link has not been clicked on). the
                      other links you have should call same function, just provide different
                      values to put into the textarea. the onmouseover event of your links
                      should change the value of textarea to temp value and then revert it
                      back to previous value, not an empty string (otherwise if you have
                      clicked on one link, but then move your mouse over another link, the
                      previously clicked on value willl be deleted.

                      --
                      Azadi Saryev
                      Sabai-dee.com
                      Vientiane, Laos
                      http://www.sabai-dee.com
                      • 8. Re: text area value change
                        insuractive Level 3
                        Something like this:

                        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

                        <html>
                        <head>
                        <title>Untitled</title>
                        <script language="JavaScript">
                        bLockTextArea = false;
                        function setTextAreaValue(sValue, bHoldValue) {
                        document.myFormName.myTextArea.value = sValue;
                        if (bHoldValue) {
                        bLockTextArea = true;
                        }
                        }

                        function clearTextAreaValue() {
                        if (!bLockTextArea) {
                        document.myFormName.myTextArea.value = "";
                        }
                        }

                        </script>
                        </head>

                        <body>

                        <form name="myFormName">
                        <textarea name="myTextArea" rows="5" cols="50"></textarea>

                        <a href="JavaScript:setTextAreaValue('test123',true)" onMouseOver="setTextAreaValue('test123',false)" onMouseOut="clearTextAreaValue()">test</a>
                        </form>

                        </body>
                        </html>