Passing text from JavaScript function to XHTML

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neogazz
    New Member
    • Apr 2010
    • 55

    Passing text from JavaScript function to XHTML

    I am trying to a pass "text sentence" from a JavaScript function into my XHTML program is this possible??

    JavaScript function validate.pdf

    Please see attached attached JavaScript coding.

    The reason why I am trying to pass text from JavaScript to my XHTML program is, because depending on whether or not a certain input field is filled out or not I want certain text to be displayed within my XHTML page...

    Regards
    Gary Wilson
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    Yes you can do that. Either you can alert the text to show the user that this field is missing. Otherwise have a div in the HTML and print the text in that div

    sample Code
    HTML:
    Code:
    <div id="errorMsg">
    </div>
    Js
    Code:
    document.getElementById('errorMsg').innerHTML=alerttext;
    Thanks and Regards
    Ramanan Kalirajan

    Comment

    • neogazz
      New Member
      • Apr 2010
      • 55

      #3
      Originally posted by RamananKaliraja n
      Yes you can do that. Either you can alert the text to show the user that this field is missing. Otherwise have a div in the HTML and print the text in that div

      sample Code
      HTML:
      Code:
      <div id="errorMsg">
      </div>
      Js
      Code:
      document.getElementById('errorMsg').innerHTML=alerttext;
      Thanks and Regards
      Ramanan Kalirajan
      Thanks Ramanan, for the info.

      In my situation I would prefer not to use 'alerttext' popup and rather display the text directly in a area (but not a text area) within the XHTML document.

      I like the div method though. Where do you place the function "document.getEl ementById('erro rMsg').innerHTM L=alerttext;", would this be inside my function "validate_requi red"??

      Thanks and regards
      Gary Wilson

      Comment

      • RamananKalirajan
        Contributor
        • Mar 2008
        • 608

        #4
        Yes you have to include that line in the validate_requir ed method. Where the condition fails.

        Thanks and Regards
        Ramanan Kalirajan

        Comment

        • neogazz
          New Member
          • Apr 2010
          • 55

          #5
          Originally posted by RamananKaliraja n
          Yes you have to include that line in the validate_requir ed method. Where the condition fails.

          Thanks and Regards
          Ramanan Kalirajan
          Thanks, I have tested this and it works well :)

          Comment

          • RamananKalirajan
            Contributor
            • Mar 2008
            • 608

            #6
            Good. Keep Moving forward. Post back if you have any doubts.

            Thanks and Regards
            Ramanan Kalirajan

            Comment

            Working...