capturing innerHTML content through POST

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gsherp
    New Member
    • May 2007
    • 34

    #1

    capturing innerHTML content through POST

    Hi,
    Is there easy way of capturing innerHTML content when the user submits the form? I tried using a hidden input field which works, however...is there any other way of doing this without using hidden input field?

    Thanks,
    Dave
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    The innerHTML of what?

    Comment

    • gsherp
      New Member
      • May 2007
      • 34

      #3
      the innerHTML of a span element with text only, no form elements.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        So you want to post this innerHTML content to the server without using form elements?

        Comment

        • dangroza
          New Member
          • Dec 2007
          • 13

          #5
          I hope this helps:

          [HTML]function sendData() {
          var form = document.getEle mentById('myFor m');
          inputNode = document.create Element("input" );
          inputNode.type = "hidden";
          inputNode.name = "hiddenKey" ;
          inputNode.value = document.getEle mentById('key') .innerHTML;
          form.appendChil d(inputNode);
          document.myForm .submit();
          }[/HTML]

          and the HTML code:
          [HTML]<form action="mypage" name="myForm" id="myForm" method="get">
          <span id="key">some data</span>
          <input type="button" onclick="sendDa ta();return false;" value="submit" />
          </form>[/HTML]

          Comment

          • dangroza
            New Member
            • Dec 2007
            • 13

            #6
            Also if you use XMLHttpRequest you later can remove all the hidden inputs from code.

            Dan

            Comment

            • gsherp
              New Member
              • May 2007
              • 34

              #7
              thanks,
              I will try this.

              Comment

              Working...