1 Reply Latest reply on Feb 21, 2013 11:20 PM by joel_pau

    How can I read the value of a text box into a variable?

    iainhunter

      I've tried the following: resVel = window.document.getElementById("txtVel").value;

       

      this normally works in javascript, but crashes when using that line in the actions for a trigger.

        • 1. Re: How can I read the value of a text box into a variable?
          joel_pau Level 5

          Hi,

           

          Both jQuery functions can be used to return text: .text() or html().

           

          1) .text().

           

          var oldText = sym.$("Text").text(); // It returns Text value.

          oldText += "new Text"; // A new string was added.

          sym.$("Text").text( oldText ); // The old and new strings are displayed.

           

          2) .html().

           

          If your text box has html tags as <strong></strong>, <p></p>, </br>, etc.

          You replace the text fonction [ .text() ] by the html fonction [ .html() ].

          So:

          var myText = sym.$("Text").html(); // You get text.

          myText += "<p><strong>new</strong> Text</p>"; // A new paragraph was added.

          sym.$("Text").html( myText ) ; // You set text.

           

          More advanced: jQuery Website.

          .text()

          .html()