-1

i am trying to load a html page with the results of a "get" from another link.The idea is when I open the page, I should see the results of the get displayed. I tried the following with javascript but with no success. The problem is I always get a submit button on the page. I want the submit to be "pre" done! Please help. Here is what I have:

<body onLoad ="subMe()">
    <script>
       function subMe(){
        document.getElementById("formButton").submit();
       }
    </script>
<div align="center">

<div style="display: hidden;">
    <form action="http://localhost:8000/getusers/" method="get">
        <input type="submit" id="formButton" />
    </form>
</div>
..
</body>

Any idea? This is linked to my previous post:Cgi C program return value to main HTML and display result

Community
  • 1
  • 1
user907810
  • 3,208
  • 10
  • 39
  • 47

3 Answers3

1

The problem is that you are submitting a button, not the form.

Try:

function subMe() {
    document.getElementsByTagName('form')[0].submit();
}

Since you have no need for the submit button, there is also no harm in removing it from the html.

Derek Henderson
  • 9,388
  • 4
  • 42
  • 71
1

I believe that you have to submit the form, not the button.

document.getElementsByTagName('form')[0].submit();
Tim Mac
  • 1,149
  • 1
  • 8
  • 17
0

submit() should be called on the form element, not on a submit button.

Fotiman
  • 111
  • 7